+async function doesAvatarExist (file: string) {
+ const avatar = await AvatarModel.loadByName(file)
+
+ return !!avatar
+}
+
+async function doesRedundancyExist (file: string) {
+ const uuid = getUUIDFromFilename(file)
+ const video = await VideoModel.loadWithFiles(uuid)
+
+ if (!video) return false
+
+ const isPlaylist = file.includes('.') === false
+
+ if (isPlaylist) {
+ const p = video.getHLSPlaylist()
+ if (!p) return false
+
+ const redundancy = await VideoRedundancyModel.loadLocalByStreamingPlaylistId(p.id)
+ return !!redundancy
+ }
+
+ const resolution = parseInt(file.split('-')[5], 10)
+ if (isNaN(resolution)) {
+ console.error('Cannot prune %s because we cannot guess guess the resolution.', file)
+ return true
+ }
+
+ const videoFile = video.getWebTorrentFile(resolution)
+ if (!videoFile) {
+ console.error('Cannot find webtorrent file of video %s - %d', video.url, resolution)
+ return true
+ }
+
+ const redundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id)
+ return !!redundancy