aboutsummaryrefslogtreecommitdiff
path: root/src/api/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/utils')
-rw-r--r--src/api/utils/Util.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js
index 905f217..e52fac2 100644
--- a/src/api/utils/Util.js
+++ b/src/api/utils/Util.js
@@ -108,6 +108,17 @@ class Util {
return hash;
}
+ static async checkIfFileExists(db, user, hash) {
+ const exists = await db.table('files')
+ .where(function() { // eslint-disable-line func-names
+ if (user) this.where('userId', user.id);
+ else this.whereNull('userId');
+ })
+ .where({ hash })
+ .first();
+ return exists;
+ }
+
static getFilenameFromPath(fullPath) {
return fullPath.replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape
}