From 09dc95f560b6f8c3fdcad6d676068908ad5e6141 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 15 May 2022 11:19:04 -0500 Subject: [PATCH] Fix:Create cache dirs on server init --- server/Server.js | 1 + server/managers/CacheManager.js | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/server/Server.js b/server/Server.js index d76906f5..41496f53 100644 --- a/server/Server.js +++ b/server/Server.js @@ -138,6 +138,7 @@ class Server { await this.checkUserMediaProgress() // Remove invalid user item progress await this.purgeMetadata() // Remove metadata folders without library item + await this.cacheManager.ensureCachePaths() await this.backupManager.init() await this.logManager.init() diff --git a/server/managers/CacheManager.js b/server/managers/CacheManager.js index c406206c..3a0e5bf1 100644 --- a/server/managers/CacheManager.js +++ b/server/managers/CacheManager.js @@ -62,9 +62,6 @@ class CacheManager { return ps.pipe(res) } - // Write cache - await this.ensureCachePaths() - if (!libraryItem.media.coverPath || !await fs.pathExists(libraryItem.media.coverPath)) { return res.sendStatus(404) } @@ -88,9 +85,6 @@ class CacheManager { } async purgeEntityCache(entityId, cachePath) { - // If purgeAll has been called... The cover cache directory no longer exists - await this.ensureCachePaths() - return Promise.all((await fs.readdir(cachePath)).reduce((promises, file) => { if (file.startsWith(entityId)) { Logger.debug(`[CacheManager] Going to purge ${file}`); @@ -117,6 +111,7 @@ class CacheManager { Logger.error(`[CacheManager] Failed to remove cache dir "${this.CachePath}"`, error) }) } + await this.ensureCachePaths() } async handleAuthorCache(res, author, options = {}) { @@ -141,9 +136,6 @@ class CacheManager { return ps.pipe(res) } - // Write cache - await this.ensureCachePaths() - let writtenFile = await resizeImage(author.imagePath, path, width, height) if (!writtenFile) return res.sendStatus(400)