diff options
Diffstat (limited to 'scripts/prune-storage.ts')
-rwxr-xr-x | scripts/prune-storage.ts | 9 |
1 files changed, 5 insertions, 4 deletions
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' | |||
13 | import { ThumbnailModel } from '../server/models/video/thumbnail' | 13 | import { ThumbnailModel } from '../server/models/video/thumbnail' |
14 | import { AvatarModel } from '../server/models/avatar/avatar' | 14 | import { AvatarModel } from '../server/models/avatar/avatar' |
15 | import { uniq, values } from 'lodash' | 15 | import { uniq, values } from 'lodash' |
16 | import { ThumbnailType } from '@shared/models' | ||
16 | 17 | ||
17 | run() | 18 | run() |
18 | .then(() => process.exit(0)) | 19 | .then(() => process.exit(0)) |
@@ -39,8 +40,8 @@ async function run () { | |||
39 | 40 | ||
40 | await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), | 41 | await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), |
41 | 42 | ||
42 | await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true)), | 43 | await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, ThumbnailType.PREVIEW)), |
43 | await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false)), | 44 | await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, ThumbnailType.MINIATURE)), |
44 | 45 | ||
45 | await pruneDirectory(CONFIG.STORAGE.AVATARS_DIR, doesAvatarExist) | 46 | await pruneDirectory(CONFIG.STORAGE.AVATARS_DIR, doesAvatarExist) |
46 | ) | 47 | ) |
@@ -92,9 +93,9 @@ function doesVideoExist (keepOnlyOwned: boolean) { | |||
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | function doesThumbnailExist (keepOnlyOwned: boolean) { | 96 | function doesThumbnailExist (keepOnlyOwned: boolean, type: ThumbnailType) { |
96 | return async (file: string) => { | 97 | return async (file: string) => { |
97 | const thumbnail = await ThumbnailModel.loadByName(file) | 98 | const thumbnail = await ThumbnailModel.loadWithVideoByName(file, type) |
98 | if (!thumbnail) return false | 99 | if (!thumbnail) return false |
99 | 100 | ||
100 | if (keepOnlyOwned) { | 101 | if (keepOnlyOwned) { |