Explorar o código

Delete thumbs when deleting a file

Pitu %!s(int64=6) %!d(string=hai) anos
pai
achega
1fe6f579f9
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      src/api/utils/Util.js

+ 3 - 0
src/api/utils/Util.js

@@ -137,8 +137,11 @@ class Util {
 	}
 
 	static async deleteFile(filename, deleteFromDB = false) {
+		const thumbName = this.getFileThumbnail(filename);
 		try {
 			await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', config.uploads.uploadFolder, filename));
+			await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', config.uploads.uploadFolder, 'thumbs', thumbName));
+			await jetpack.removeAsync(path.join(__dirname, '..', '..', '..', config.uploads.uploadFolder, 'thumbs', 'square', thumbName));
 			if (deleteFromDB) {
 				await db.table('files').where('name', filename).delete();
 			}