Improve update host script

pull/364/head
Chocobozzz 2018-03-20 08:54:24 +01:00
parent 07aa93a8f2
commit c91de74372
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 7 additions and 12 deletions

View File

@ -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)