diff options
| author | Pitu <[email protected]> | 2020-12-27 04:48:03 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-12-27 04:48:03 +0900 |
| commit | aa7d2453171b3a596a1be6676eaf39cc93fe178f (patch) | |
| tree | 8896bc57bd01ef1ed16e5d066f57be2bcd8d856f /src/api/utils | |
| parent | Fixes chunked uploads not being saved to albums or thumbnails (diff) | |
| download | host.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.js | 11 |
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 } |