]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/prune-storage.ts
Translated using Weblate (Toki Pona (tok))
[github/Chocobozzz/PeerTube.git] / scripts / prune-storage.ts
index 9df80d5035154cb2eb8d1a6f257eed26f90a6d79..bb1e8e024041e74c4df41d72988db9bf040ea033 100755 (executable)
@@ -1,21 +1,19 @@
-import { registerTSPaths } from '../server/helpers/register-ts-paths'
-registerTSPaths()
-
-import { start, get } from 'prompt'
-import { join, basename } from 'path'
+import { map } from 'bluebird'
+import { readdir, remove, stat } from 'fs-extra'
+import { uniq, values } from 'lodash'
+import { basename, join } from 'path'
+import { get, start } from 'prompt'
+import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
+import { VideoFileModel } from '@server/models/video/video-file'
+import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
+import { ThumbnailType } from '@shared/models'
+import { getUUIDFromFilename } from '../server/helpers/utils'
 import { CONFIG } from '../server/initializers/config'
-import { VideoModel } from '../server/models/video/video'
 import { initDatabaseModels } from '../server/initializers/database'
-import { readdir, remove, stat } from 'fs-extra'
+import { ActorImageModel } from '../server/models/actor/actor-image'
 import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
-import { map } from 'bluebird'
-import { getUUIDFromFilename } from '../server/helpers/utils'
 import { ThumbnailModel } from '../server/models/video/thumbnail'
-import { ActorImageModel } from '../server/models/actor/actor-image'
-import { uniq, values } from 'lodash'
-import { ThumbnailType } from '@shared/models'
-import { VideoFileModel } from '@server/models/video/video-file'
-import { HLS_REDUNDANCY_DIRECTORY } from '@server/initializers/constants'
+import { VideoModel } from '../server/models/video/video'
 
 run()
   .then(() => process.exit(0))
@@ -40,6 +38,9 @@ async function run () {
 
   toDelete = toDelete.concat(
     await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesWebTorrentFileExist()),
+
+    await pruneDirectory(HLS_STREAMING_PLAYLIST_DIRECTORY, doesHLSPlaylistExist()),
+
     await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesTorrentFileExist()),
 
     await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist),
@@ -94,6 +95,10 @@ function doesWebTorrentFileExist () {
   return (filePath: string) => VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath))
 }
 
+function doesHLSPlaylistExist () {
+  return (hlsPath: string) => VideoStreamingPlaylistModel.doesOwnedHLSPlaylistExist(basename(hlsPath))
+}
+
 function doesTorrentFileExist () {
   return (filePath: string) => VideoFileModel.doesOwnedTorrentFileExist(basename(filePath))
 }