]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/update-host.ts
Add ability to forbid user to upload video
[github/Chocobozzz/PeerTube.git] / scripts / update-host.ts
index 5e69e4172bd9629b537605abce809b8f602ee026..06d84a658ca416107372efec502ac8424b62525c 100755 (executable)
@@ -1,8 +1,5 @@
-import { readFileSync, writeFileSync } from 'fs'
-import { join } from 'path'
-import * as parseTorrent from 'parse-torrent'
+import * as Promise from 'bluebird'
 
-import { CONFIG, STATIC_PATHS } from '../server/initializers/constants'
 import { database as db } from '../server/initializers/database'
 import { hasFriends } from '../server/lib/friends'
 
@@ -20,11 +17,18 @@ db.init(true)
     return db.Video.list()
   })
   .then(videos => {
+    const tasks: Promise<any>[] = []
+
     videos.forEach(video => {
+      console.log('Updating video ' + video.uuid)
+
       video.VideoFiles.forEach(file => {
-        video.createTorrentAndSetInfoHash(file)
+        tasks.push(video.createTorrentAndSetInfoHash(file))
       })
     })
 
+    return Promise.all(tasks)
+  })
+  .then(() => {
     process.exit(0)
   })