]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/prune-storage.ts
Video-watch hooks modifications for videojs
[github/Chocobozzz/PeerTube.git] / scripts / prune-storage.ts
index d6dff8247bc78a9849e0af63fb61b12e85e64431..c8968013b8dbfd0573c17af4d35d73013aa6bcf9 100755 (executable)
@@ -1,3 +1,6 @@
+import { registerTSPaths } from '../server/helpers/register-ts-paths'
+registerTSPaths()
+
 import * as prompt from 'prompt'
 import { join } from 'path'
 import { CONFIG } from '../server/initializers/config'
@@ -9,6 +12,7 @@ import * as Bluebird from 'bluebird'
 import { getUUIDFromFilename } from '../server/helpers/utils'
 import { ThumbnailModel } from '../server/models/video/thumbnail'
 import { AvatarModel } from '../server/models/avatar/avatar'
+import { uniq, values } from 'lodash'
 
 run()
   .then(() => process.exit(0))
@@ -18,6 +22,13 @@ run()
   })
 
 async function run () {
+  const dirs = values(CONFIG.STORAGE)
+
+  if (uniq(dirs).length !== dirs.length) {
+    console.error('Cannot prune storage because you put multiple storage keys in the same directory.')
+    process.exit(0)
+  }
+
   await initDatabaseModels(true)
 
   let toDelete: string[] = []