aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-12 16:23:19 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-16 10:36:44 +0100
commita8b1b40485145ac1eae513a661d7dd6e0986ce96 (patch)
tree79436a042f1ed350278dd69e365f37ee623aa539 /scripts
parent0472d474fdadd05211fb4f90ce275801db515d08 (diff)
downloadPeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.gz
PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.zst
PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.zip
Generate a name for thumbnails
Allows aggressive caching
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/prune-storage.ts9
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'
13import { ThumbnailModel } from '../server/models/video/thumbnail' 13import { ThumbnailModel } from '../server/models/video/thumbnail'
14import { AvatarModel } from '../server/models/avatar/avatar' 14import { AvatarModel } from '../server/models/avatar/avatar'
15import { uniq, values } from 'lodash' 15import { uniq, values } from 'lodash'
16import { ThumbnailType } from '@shared/models'
16 17
17run() 18run()
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
95function doesThumbnailExist (keepOnlyOwned: boolean) { 96function 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) {