aboutsummaryrefslogtreecommitdiff
path: root/src/api/utils
diff options
context:
space:
mode:
authorPitu <[email protected]>2020-12-27 04:48:03 +0900
committerPitu <[email protected]>2020-12-27 04:48:03 +0900
commitaa7d2453171b3a596a1be6676eaf39cc93fe178f (patch)
tree8896bc57bd01ef1ed16e5d066f57be2bcd8d856f /src/api/utils
parentFixes chunked uploads not being saved to albums or thumbnails (diff)
downloadhost.fuwn.me-aa7d2453171b3a596a1be6676eaf39cc93fe178f.tar.xz
host.fuwn.me-aa7d2453171b3a596a1be6676eaf39cc93fe178f.zip
feat: Add hash checking for chunked uploads
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
}