X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fprune-storage.ts;h=58d24816e345e5e60c966c97999add985c31d63a;hb=0c1a77e9ccf915184c431145a8b326d4ce271b46;hp=788d97997d2c1eadc971e1e6638c7ed912be386d;hpb=a8b1b40485145ac1eae513a661d7dd6e0986ce96;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 788d97997..58d24816e 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -11,7 +11,7 @@ import { VideoRedundancyModel } from '../server/models/redundancy/video-redundan import * as Bluebird from 'bluebird' import { getUUIDFromFilename } from '../server/helpers/utils' import { ThumbnailModel } from '../server/models/video/thumbnail' -import { AvatarModel } from '../server/models/avatar/avatar' +import { ActorImageModel } from '../server/models/actor/actor-image' import { uniq, values } from 'lodash' import { ThumbnailType } from '@shared/models' @@ -34,6 +34,8 @@ async function run () { let toDelete: string[] = [] + console.log('Detecting files to remove, it could take a while...') + toDelete = toDelete.concat( await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesVideoExist(true)), await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesVideoExist(true)), @@ -43,7 +45,7 @@ async function run () { 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) + await pruneDirectory(CONFIG.STORAGE.ACTOR_IMAGES, doesActorImageExist) ) const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR) @@ -87,7 +89,7 @@ async function pruneDirectory (directory: string, existFun: ExistFun) { function doesVideoExist (keepOnlyOwned: boolean) { return async (file: string) => { const uuid = getUUIDFromFilename(file) - const video = await VideoModel.loadByUUID(uuid) + const video = await VideoModel.load(uuid) return video && (keepOnlyOwned === false || video.isOwned()) } @@ -95,7 +97,7 @@ function doesVideoExist (keepOnlyOwned: boolean) { function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType) { return async (file: string) => { - const thumbnail = await ThumbnailModel.loadWithVideoByName(file, type) + const thumbnail = await ThumbnailModel.loadByFilename(file, type) if (!thumbnail) return false if (keepOnlyOwned) { @@ -107,10 +109,10 @@ function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType) { } } -async function doesAvatarExist (file: string) { - const avatar = await AvatarModel.loadByName(file) +async function doesActorImageExist (file: string) { + const image = await ActorImageModel.loadByName(file) - return !!avatar + return !!image } async function doesRedundancyExist (file: string) {