1 import { getServerAccount } from '../server/helpers'
2 import { initDatabaseModels } from '../server/initializers'
3 import { AccountFollowModel } from '../server/models/account/account-follow'
4 import { VideoModel } from '../server/models/video/video'
6 initDatabaseModels(true)
8 return getServerAccount()
10 .then(serverAccount => {
11 return AccountFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined)
16 .then(hasFollowing => {
17 if (hasFollowing === true) {
18 console.log('Cannot update host because you follow other servers!')
22 console.log('Updating torrent files.')
23 return VideoModel.list()
26 const tasks: Promise<any>[] = []
28 videos.forEach(video => {
29 console.log('Updating video ' + video.uuid)
31 video.VideoFiles.forEach(file => {
32 tasks.push(video.createTorrentAndSetInfoHash(file))
36 return Promise.all(tasks)