aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/prune-storage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/prune-storage.ts')
-rwxr-xr-xscripts/prune-storage.ts33
1 files changed, 19 insertions, 14 deletions
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts
index 9df80d503..bb1e8e024 100755
--- a/scripts/prune-storage.ts
+++ b/scripts/prune-storage.ts
@@ -1,21 +1,19 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { map } from 'bluebird'
2registerTSPaths() 2import { readdir, remove, stat } from 'fs-extra'
3 3import { uniq, values } from 'lodash'
4import { start, get } from 'prompt' 4import { basename, join } from 'path'
5import { join, basename } from 'path' 5import { get, start } from 'prompt'
6import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
7import { VideoFileModel } from '@server/models/video/video-file'
8import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
9import { ThumbnailType } from '@shared/models'
10import { getUUIDFromFilename } from '../server/helpers/utils'
6import { CONFIG } from '../server/initializers/config' 11import { CONFIG } from '../server/initializers/config'
7import { VideoModel } from '../server/models/video/video'
8import { initDatabaseModels } from '../server/initializers/database' 12import { initDatabaseModels } from '../server/initializers/database'
9import { readdir, remove, stat } from 'fs-extra' 13import { ActorImageModel } from '../server/models/actor/actor-image'
10import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' 14import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
11import { map } from 'bluebird'
12import { getUUIDFromFilename } from '../server/helpers/utils'
13import { ThumbnailModel } from '../server/models/video/thumbnail' 15import { ThumbnailModel } from '../server/models/video/thumbnail'
14import { ActorImageModel } from '../server/models/actor/actor-image' 16import { VideoModel } from '../server/models/video/video'
15import { uniq, values } from 'lodash'
16import { ThumbnailType } from '@shared/models'
17import { VideoFileModel } from '@server/models/video/video-file'
18import { HLS_REDUNDANCY_DIRECTORY } from '@server/initializers/constants'
19 17
20run() 18run()
21 .then(() => process.exit(0)) 19 .then(() => process.exit(0))
@@ -40,6 +38,9 @@ async function run () {
40 38
41 toDelete = toDelete.concat( 39 toDelete = toDelete.concat(
42 await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()), 40 await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()),
41
42 await pruneDirectory(HLS_STREAMING_PLAYLIST_DIRECTORY, doesHLSPlaylistExist()),
43
43 await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()), 44 await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()),
44 45
45 await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist), 46 await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist),
@@ -94,6 +95,10 @@ function doesWebTorrentFileExist () {
94 return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath)) 95 return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath))
95} 96}
96 97
98function doesHLSPlaylistExist () {
99 return (hlsPath: string) => VideoStreamingPlaylistModel.doesOwnedHLSPlaylistExist(basename(hlsPath))
100}
101
97function doesTorrentFileExist () { 102function doesTorrentFileExist () {
98 return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath)) 103 return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath))
99} 104}