Fix prune storage script with some configs
authorChocobozzz <me@florianbigard.com>
Thu, 15 Aug 2019 09:56:54 +0000 (11:56 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 15 Aug 2019 09:56:54 +0000 (11:56 +0200)
scripts/prune-storage.ts

index d6dff8247bc78a9849e0af63fb61b12e85e64431..df4bdeebe0c2b18f01694cfe899993e8b8070331 100755 (executable)
@@ -9,6 +9,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 +19,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[] = []