Fix:Create cache dirs on server init

This commit is contained in:
advplyr 2022-05-15 11:19:04 -05:00
parent 853858825b
commit 09dc95f560
2 changed files with 2 additions and 9 deletions

View File

@ -138,6 +138,7 @@ class Server {
await this.checkUserMediaProgress() // Remove invalid user item progress await this.checkUserMediaProgress() // Remove invalid user item progress
await this.purgeMetadata() // Remove metadata folders without library item await this.purgeMetadata() // Remove metadata folders without library item
await this.cacheManager.ensureCachePaths()
await this.backupManager.init() await this.backupManager.init()
await this.logManager.init() await this.logManager.init()

View File

@ -62,9 +62,6 @@ class CacheManager {
return ps.pipe(res) return ps.pipe(res)
} }
// Write cache
await this.ensureCachePaths()
if (!libraryItem.media.coverPath || !await fs.pathExists(libraryItem.media.coverPath)) { if (!libraryItem.media.coverPath || !await fs.pathExists(libraryItem.media.coverPath)) {
return res.sendStatus(404) return res.sendStatus(404)
} }
@ -88,9 +85,6 @@ class CacheManager {
} }
async purgeEntityCache(entityId, cachePath) { 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) => { return Promise.all((await fs.readdir(cachePath)).reduce((promises, file) => {
if (file.startsWith(entityId)) { if (file.startsWith(entityId)) {
Logger.debug(`[CacheManager] Going to purge ${file}`); Logger.debug(`[CacheManager] Going to purge ${file}`);
@ -117,6 +111,7 @@ class CacheManager {
Logger.error(`[CacheManager] Failed to remove cache dir "${this.CachePath}"`, error) Logger.error(`[CacheManager] Failed to remove cache dir "${this.CachePath}"`, error)
}) })
} }
await this.ensureCachePaths()
} }
async handleAuthorCache(res, author, options = {}) { async handleAuthorCache(res, author, options = {}) {
@ -141,9 +136,6 @@ class CacheManager {
return ps.pipe(res) return ps.pipe(res)
} }
// Write cache
await this.ensureCachePaths()
let writtenFile = await resizeImage(author.imagePath, path, width, height) let writtenFile = await resizeImage(author.imagePath, path, width, height)
if (!writtenFile) return res.sendStatus(400) if (!writtenFile) return res.sendStatus(400)