diff options
| author | Pitu <[email protected]> | 2020-07-18 03:37:52 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-07-18 03:37:52 +0900 |
| commit | b70a75da1af00e932319b3ba24ccde860a6c7f48 (patch) | |
| tree | 71e1fd4faf15fd83364c9ab6c588f58837050bc6 /src/api/utils/Util.js | |
| parent | Fix deleting files without thumb (diff) | |
| download | host.fuwn.me-b70a75da1af00e932319b3ba24ccde860a6c7f48.tar.xz host.fuwn.me-b70a75da1af00e932319b3ba24ccde860a6c7f48.zip | |
Fix for real
Diffstat (limited to 'src/api/utils/Util.js')
| -rw-r--r-- | src/api/utils/Util.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index 4674dde..885228f 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -154,6 +154,13 @@ class Util { const thumbName = this.getFileThumbnail(filename); try { await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, filename)); + if (thumbName) { + const thumb = path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', thumbName); + const thumbSquare = path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, 'thumbs', 'square', thumbName); + if (await jetpack.existsAsync(thumb)) jetpack.removeAsync(thumb); + if (await jetpack.existsAsync(thumbSquare)) jetpack.removeAsync(thumbSquare); + } + if (deleteFromDB) { await db.table('files').where('name', filename).delete(); } @@ -161,14 +168,6 @@ 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) { |