From c91de74372432dee446bf837121ff40359185f4e Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Tue, 20 Mar 2018 08:54:24 +0100
Subject: Improve update host script

---
 scripts/update-host.ts | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/scripts/update-host.ts b/scripts/update-host.ts
index 3fb5f1972..ed8b999a9 100755
--- a/scripts/update-host.ts
+++ b/scripts/update-host.ts
@@ -22,18 +22,13 @@ initDatabaseModels(true)
     console.log('Updating torrent files.')
     return VideoModel.list()
   })
-  .then(videos => {
-    const tasks: Promise<any>[] = []
-
-    videos.forEach(video => {
-      console.log('Updating video ' + video.uuid)
-
-      video.VideoFiles.forEach(file => {
-        tasks.push(video.createTorrentAndSetInfoHash(file))
-      })
-    })
-
-    return Promise.all(tasks)
+  .then(async videos => {
+    for (const video of videos) {
+      for (const file of video.VideoFiles) {
+        await video.createTorrentAndSetInfoHash(file)
+        console.log('Updated video ' + video.uuid)
+      }
+    }
   })
   .then(() => {
     process.exit(0)
-- 
cgit v1.2.3