X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fprune-storage.ts;h=dcb1fcf9024db420504126917cedcecee0183e70;hb=285981f4dd1bdeaac32cb3f99be55edac9ef3f78;hp=2b04e906d999ba4d1ffb54148724f33ce1bb6ab5;hpb=80fdaf064562aff968f4c9cea1cf220bc12a70da;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 2b04e906d..dcb1fcf90 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.loadByFilename(file, type) if (!thumbnail) return false if (keepOnlyOwned) { @@ -161,7 +162,8 @@ async function askConfirmation () { } prompt.get(schema, function (err, result) { if (err) return rej(err) - return res(result.confirm && result.confirm.match(/y/) !== null) + + return res(result.confirm?.match(/y/) !== null) }) }) }