diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gen-thumbs.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js index f0eb72a0..cecedc82 100644 --- a/src/gen-thumbs.js +++ b/src/gen-thumbs.js @@ -397,7 +397,18 @@ export function getDimensionsOfImagePath(mediaPath, cache) { throw new Error(`Expected mediaPath to be included in cache, got ${mediaPath}`); } - const {width, height} = thumbnailCacheEntryToDetails(cacheEntry); + const details = thumbnailCacheEntryToDetails(cacheEntry); + + if (!details) { + throw new Error(`Couldn't determine any details for this image (${mediaPath})`); + } + + const {width, height} = details; + + if (typeof width !== 'number' && typeof height !== 'number') { + throw new Error(`Details for this image don't appear to contain dimensions (${mediaPath})`); + } + return [width, height]; } @@ -792,6 +803,13 @@ export async function refreshThumbnailCache(cache, {mediaPath, queueSize}) { .map(([imagePath, cacheEntry]) => async () => { const details = thumbnailCacheEntryToDetails(cacheEntry); + // Couldn't parse this entry, it won't be used later on. + // But leave it around just in case some other version of hsmusic + // can get use out of it. + if (!details) { + return; + } + const {tackbust, width, height} = details; let {md5, mtime} = details; |