From 1c6cd7499b3f34611a3f9a8fb344022e360418b6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 20 Apr 2022 17:34:20 -0500 Subject: [PATCH] Remove old cover method make sure cover filename is an actual image --- server/managers/CoverManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/managers/CoverManager.js b/server/managers/CoverManager.js index c85352bc..10ba1091 100644 --- a/server/managers/CoverManager.js +++ b/server/managers/CoverManager.js @@ -51,11 +51,12 @@ class CoverManager { async removeOldCovers(dirpath, newCoverExt) { var filesInDir = await this.getFilesInDirectory(dirpath) + const imageExtensions = ['.jpeg', '.jpg', '.png', '.webp', '.jiff'] for (let i = 0; i < filesInDir.length; i++) { var file = filesInDir[i] - var _extname = Path.extname(file) + var _extname = Path.extname(file).toLowerCase() var _filename = Path.basename(file, _extname) - if (_filename === 'cover' && _extname !== newCoverExt) { + if (_filename === 'cover' && _extname !== newCoverExt && imageExtensions.includes(_extname)) { var filepath = Path.join(dirpath, file) Logger.debug(`[CoverManager] Removing old cover from metadata "${filepath}"`) await this.removeFile(filepath)