diff options
| author | Pitu <[email protected]> | 2020-07-18 03:35:08 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-07-18 03:35:08 +0900 |
| commit | 6dd7500084bf7306f66e8f65367b90f1049e3f15 (patch) | |
| tree | 9cf8eeff1a3b0a188c2907f76ad6f489a1772776 /src/api/utils | |
| parent | Fix url retrieval of uploaded file (diff) | |
| download | host.fuwn.me-6dd7500084bf7306f66e8f65367b90f1049e3f15.tar.xz host.fuwn.me-6dd7500084bf7306f66e8f65367b90f1049e3f15.zip | |
Fix deleting files without thumb
Diffstat (limited to 'src/api/utils')
| -rw-r--r-- | src/api/utils/Util.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index 91ab663..4674dde 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -154,8 +154,6 @@ class Util { const thumbName = this.getFileThumbnail(filename); try { await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, filename)); - await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', thumbName)); - await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', 'square', thumbName)); if (deleteFromDB) { await db.table('files').where('name', filename).delete(); } @@ -163,6 +161,14 @@ class Util { log.error(`There was an error removing the file < ${filename} >`); log.error(error); } + + try { + await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', thumbName)); + await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', 'square', thumbName)); + } catch (error) { + log.error(`There was an error removing the thumbs for file < ${filename} >`); + log.error(error); + } } static async deleteAllFilesFromAlbum(id) { |