From 69fa54a0b21999b4fcafea9223ca37888c30d627 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 Sep 2018 19:42:05 +0200 Subject: Dirty webtorrent fix to wait FS sync --- server/helpers/webtorrent.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index d35b3a710..87c029fcd 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -1,5 +1,4 @@ import { logger } from './logger' -import { generateVideoTmpPath } from './utils' import * as WebTorrent from 'webtorrent' import { remove } from 'fs-extra' import { CONFIG } from '../initializers' @@ -26,7 +25,10 @@ function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: str .then(() => rej(new Error('Cannot import torrent ' + torrentId + ': there are multiple files in it'))) } - torrent.on('done', () => res(join(CONFIG.STORAGE.VIDEOS_DIR, torrent.files[ 0 ].path))) + torrent.on('done', () => { + // FIXME: Dirty fix, we need to wait the FS sync but webtorrent does not provide such method + setTimeout(() => res(join(CONFIG.STORAGE.VIDEOS_DIR, torrent.files[ 0 ].name)), 1000) + }) }) torrent.on('error', err => rej(err)) -- cgit v1.2.3