X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fupdate-host.ts;h=ed8b999a9f42c8d43a24e2a1b9b0e1425b3a0516;hb=379acb21bcc491efdc0118ea714790bb34238d66;hp=ba4656b75cb268192175fc5bdb98c8d8a0cb75a0;hpb=3fd3ab2d34d512b160a5e6084d7609be7b4f4452;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/update-host.ts b/scripts/update-host.ts index ba4656b75..ed8b999a9 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,14 +1,14 @@ -import { getServerAccount } from '../server/helpers' -import { initDatabase } from '../server/initializers' -import { AccountFollowModel } from '../server/models/account/account-follow' +import { getServerActor } from '../server/helpers/utils' +import { initDatabaseModels } from '../server/initializers' +import { ActorFollowModel } from '../server/models/activitypub/actor-follow' import { VideoModel } from '../server/models/video/video' -initDatabase(true) +initDatabaseModels(true) .then(() => { - return getServerAccount() + return getServerActor() }) .then(serverAccount => { - return AccountFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) + return ActorFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) }) .then(res => { return res.total > 0 @@ -22,18 +22,13 @@ initDatabase(true) console.log('Updating torrent files.') return VideoModel.list() }) - .then(videos => { - const tasks: Promise[] = [] - - 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)