diff options
Diffstat (limited to 'scripts/prune-storage.ts')
-rwxr-xr-x | scripts/prune-storage.ts | 33 |
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 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | 1 | import { map } from 'bluebird' |
2 | registerTSPaths() | 2 | import { readdir, remove, stat } from 'fs-extra' |
3 | 3 | import { uniq, values } from 'lodash' | |
4 | import { start, get } from 'prompt' | 4 | import { basename, join } from 'path' |
5 | import { join, basename } from 'path' | 5 | import { get, start } from 'prompt' |
6 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' | ||
7 | import { VideoFileModel } from '@server/models/video/video-file' | ||
8 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | ||
9 | import { ThumbnailType } from '@shared/models' | ||
10 | import { getUUIDFromFilename } from '../server/helpers/utils' | ||
6 | import { CONFIG } from '../server/initializers/config' | 11 | import { CONFIG } from '../server/initializers/config' |
7 | import { VideoModel } from '../server/models/video/video' | ||
8 | import { initDatabaseModels } from '../server/initializers/database' | 12 | import { initDatabaseModels } from '../server/initializers/database' |
9 | import { readdir, remove, stat } from 'fs-extra' | 13 | import { ActorImageModel } from '../server/models/actor/actor-image' |
10 | import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' | 14 | import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' |
11 | import { map } from 'bluebird' | ||
12 | import { getUUIDFromFilename } from '../server/helpers/utils' | ||
13 | import { ThumbnailModel } from '../server/models/video/thumbnail' | 15 | import { ThumbnailModel } from '../server/models/video/thumbnail' |
14 | import { ActorImageModel } from '../server/models/actor/actor-image' | 16 | import { VideoModel } from '../server/models/video/video' |
15 | import { uniq, values } from 'lodash' | ||
16 | import { ThumbnailType } from '@shared/models' | ||
17 | import { VideoFileModel } from '@server/models/video/video-file' | ||
18 | import { HLS_REDUNDANCY_DIRECTORY } from '@server/initializers/constants' | ||
19 | 17 | ||
20 | run() | 18 | run() |
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 | ||
98 | function doesHLSPlaylistExist () { | ||
99 | return (hlsPath: string) => VideoStreamingPlaylistModel.doesOwnedHLSPlaylistExist(basename(hlsPath)) | ||
100 | } | ||
101 | |||
97 | function doesTorrentFileExist () { | 102 | function doesTorrentFileExist () { |
98 | return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath)) | 103 | return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath)) |
99 | } | 104 | } |