diff options
| author | Pitu <[email protected]> | 2019-03-12 06:18:32 +0000 |
|---|---|---|
| committer | Pitu <[email protected]> | 2019-03-12 06:18:32 +0000 |
| commit | 4277db90f670f72cd3729ad88b91a4d4993de1cf (patch) | |
| tree | 8c7b86dd3817fc9b8a7f5495b6960d514dda0500 /src/api/utils/Util.js | |
| parent | Add uuids (diff) | |
| download | host.fuwn.me-4277db90f670f72cd3729ad88b91a4d4993de1cf.tar.xz host.fuwn.me-4277db90f670f72cd3729ad88b91a4d4993de1cf.zip | |
Possible fix for files not being purged
Diffstat (limited to 'src/api/utils/Util.js')
| -rw-r--r-- | src/api/utils/Util.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index a514e20..a8e1754 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -109,6 +109,8 @@ class Util { length: parseInt(process.env.GENERATED_FILENAME_LENGTH, 10), capitalization: 'lowercase' }) + path.extname(name).toLowerCase(); + + // TODO: Change this to look for the file in the db instead of in the filesystem const exists = jetpack.exists(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, filename)); if (!exists) return filename; if (i < 5) return retry(i + 1); @@ -171,9 +173,8 @@ class Util { try { const files = await db.table('files').where({ albumId: id }); for (const file of files) { - await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, file)); + await this.deleteFile(file.name, true) } - await db.table('files').where({ albumId: id }).delete(); } catch (error) { log.error(error); } @@ -183,9 +184,8 @@ class Util { try { const files = await db.table('files').where({ userId: id }); for (const file of files) { - await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, file)); + await this.deleteFile(file.name, true) } - await db.table('files').where({ userId: id }).delete(); } catch (error) { log.error(error); } |