From 93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Aug 2017 11:36:23 +0200 Subject: Move video file metadata in their own table Will be used for user video quotas and multiple video resolutions --- scripts/update-host.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'scripts/update-host.ts') diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 23e8d5ef3..5e69e4172 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,4 +1,5 @@ import { readFileSync, writeFileSync } from 'fs' +import { join } from 'path' import * as parseTorrent from 'parse-torrent' import { CONFIG, STATIC_PATHS } from '../server/initializers/constants' @@ -19,17 +20,10 @@ db.init(true) return db.Video.list() }) .then(videos => { - videos.forEach(function (video) { - const torrentName = video.id + '.torrent' - const torrentPath = CONFIG.STORAGE.TORRENTS_DIR + torrentName - const filename = video.id + video.extname - - const parsed = parseTorrent(readFileSync(torrentPath)) - parsed.announce = [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOST + '/tracker/socket' ] - parsed.urlList = [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + filename ] - - const buf = parseTorrent.toTorrentFile(parsed) - writeFileSync(torrentPath, buf) + videos.forEach(video => { + video.VideoFiles.forEach(file => { + video.createTorrentAndSetInfoHash(file) + }) }) process.exit(0) -- cgit v1.2.3