Make it compile at least
[oweals/peertube.git] / scripts / update-host.ts
1 import { database as db } from '../server/initializers/database'
2 // import { hasFriends } from '../server/lib/friends'
3
4 db.init(true)
5   .then(() => {
6     // FIXME: check if has followers
7     // return hasFriends()
8     return true
9   })
10   .then(itHasFriends => {
11     if (itHasFriends === true) {
12       console.log('Cannot update host because you have friends!')
13       process.exit(-1)
14     }
15
16     console.log('Updating torrent files.')
17     return db.Video.list()
18   })
19   .then(videos => {
20     const tasks: Promise<any>[] = []
21
22     videos.forEach(video => {
23       console.log('Updating video ' + video.uuid)
24
25       video.VideoFiles.forEach(file => {
26         tasks.push(video.createTorrentAndSetInfoHash(file))
27       })
28     })
29
30     return Promise.all(tasks)
31   })
32   .then(() => {
33     process.exit(0)
34   })