]>
Commit | Line | Data |
---|---|---|
75d612ce | 1 | import { readFileSync, writeFileSync } from 'fs' |
93e1258c | 2 | import { join } from 'path' |
75d612ce C |
3 | import * as parseTorrent from 'parse-torrent' |
4 | ||
5 | import { CONFIG, STATIC_PATHS } from '../server/initializers/constants' | |
6 | import { database as db } from '../server/initializers/database' | |
7 | import { hasFriends } from '../server/lib/friends' | |
8 | ||
6fcd19ba C |
9 | db.init(true) |
10 | .then(() => { | |
11 | return hasFriends() | |
12 | }) | |
13 | .then(itHasFriends => { | |
75d612ce C |
14 | if (itHasFriends === true) { |
15 | console.log('Cannot update host because you have friends!') | |
16 | process.exit(-1) | |
17 | } | |
18 | ||
19 | console.log('Updating torrent files.') | |
6fcd19ba C |
20 | return db.Video.list() |
21 | }) | |
22 | .then(videos => { | |
93e1258c C |
23 | videos.forEach(video => { |
24 | video.VideoFiles.forEach(file => { | |
25 | video.createTorrentAndSetInfoHash(file) | |
26 | }) | |
75d612ce | 27 | }) |
6fcd19ba C |
28 | |
29 | process.exit(0) | |
75d612ce | 30 | }) |