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))
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)
)
}
}
-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) {
}
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)
})
})
}