]>
Commit | Line | Data |
---|---|---|
fdbda9e3 | 1 | import * as Promise from 'bluebird' |
75d612ce | 2 | |
75d612ce C |
3 | import { database as db } from '../server/initializers/database' |
4 | import { hasFriends } from '../server/lib/friends' | |
5 | ||
6fcd19ba C |
6 | db.init(true) |
7 | .then(() => { | |
8 | return hasFriends() | |
9 | }) | |
10 | .then(itHasFriends => { | |
75d612ce C |
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.') | |
6fcd19ba C |
17 | return db.Video.list() |
18 | }) | |
19 | .then(videos => { | |
fdbda9e3 C |
20 | const tasks: Promise<any>[] = [] |
21 | ||
93e1258c | 22 | videos.forEach(video => { |
fdbda9e3 C |
23 | console.log('Updating video ' + video.uuid) |
24 | ||
93e1258c | 25 | video.VideoFiles.forEach(file => { |
fdbda9e3 | 26 | tasks.push(video.createTorrentAndSetInfoHash(file)) |
93e1258c | 27 | }) |
75d612ce | 28 | }) |
6fcd19ba | 29 | |
fdbda9e3 C |
30 | return Promise.all(tasks) |
31 | }) | |
32 | .then(() => { | |
6fcd19ba | 33 | process.exit(0) |
75d612ce | 34 | }) |