From a8b1b40485145ac1eae513a661d7dd6e0986ce96 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Feb 2021 16:23:19 +0100 Subject: Generate a name for thumbnails Allows aggressive caching --- scripts/prune-storage.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts/prune-storage.ts') diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 1def1d792..788d97997 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -13,6 +13,7 @@ import { getUUIDFromFilename } from '../server/helpers/utils' import { ThumbnailModel } from '../server/models/video/thumbnail' import { AvatarModel } from '../server/models/avatar/avatar' import { uniq, values } from 'lodash' +import { ThumbnailType } from '@shared/models' run() .then(() => process.exit(0)) @@ -39,8 +40,8 @@ async function run () { await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), - await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true)), - await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false)), + await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, ThumbnailType.PREVIEW)), + await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, ThumbnailType.MINIATURE)), await pruneDirectory(CONFIG.STORAGE.AVATARS_DIR, doesAvatarExist) ) @@ -92,9 +93,9 @@ function doesVideoExist (keepOnlyOwned: boolean) { } } -function doesThumbnailExist (keepOnlyOwned: boolean) { +function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType) { return async (file: string) => { - const thumbnail = await ThumbnailModel.loadByName(file) + const thumbnail = await ThumbnailModel.loadWithVideoByName(file, type) if (!thumbnail) return false if (keepOnlyOwned) { -- cgit v1.2.3