Wrap ensureDir in try-catch blocks

This commit is contained in:
mikiher 2025-12-01 18:00:34 +02:00
parent 329e3c7179
commit 5f1edcb609
5 changed files with 67 additions and 22 deletions

View file

@ -24,10 +24,15 @@ class CacheManager {
this.ImageCachePath = Path.join(this.CachePath, 'images')
this.ItemCachePath = Path.join(this.CachePath, 'items')
await fs.ensureDir(this.CachePath)
await fs.ensureDir(this.CoverCachePath)
await fs.ensureDir(this.ImageCachePath)
await fs.ensureDir(this.ItemCachePath)
try {
await fs.ensureDir(this.CachePath)
await fs.ensureDir(this.CoverCachePath)
await fs.ensureDir(this.ImageCachePath)
await fs.ensureDir(this.ItemCachePath)
} catch (error) {
Logger.error(`[CacheManager] Failed to create cache directories at "${this.CachePath}": ${error.message}`)
throw new Error(`[CacheManager] Failed to create cache directories at "${this.CachePath}"`, { cause: error })
}
}
async handleCoverCache(res, libraryItemId, options = {}) {