diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-12 16:23:19 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-02-16 10:36:44 +0100 |
commit | a8b1b40485145ac1eae513a661d7dd6e0986ce96 (patch) | |
tree | 79436a042f1ed350278dd69e365f37ee623aa539 /scripts/prune-storage.ts | |
parent | 0472d474fdadd05211fb4f90ce275801db515d08 (diff) | |
download | PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.gz PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.zst PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.zip |
Generate a name for thumbnails
Allows aggressive caching
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) { |