diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/webtorrent.ts | 6 |
1 files changed, 4 insertions, 2 deletions
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 @@ | |||
1 | import { logger } from './logger' | 1 | import { logger } from './logger' |
2 | import { generateVideoTmpPath } from './utils' | ||
3 | import * as WebTorrent from 'webtorrent' | 2 | import * as WebTorrent from 'webtorrent' |
4 | import { remove } from 'fs-extra' | 3 | import { remove } from 'fs-extra' |
5 | import { CONFIG } from '../initializers' | 4 | import { CONFIG } from '../initializers' |
@@ -26,7 +25,10 @@ function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: str | |||
26 | .then(() => rej(new Error('Cannot import torrent ' + torrentId + ': there are multiple files in it'))) | 25 | .then(() => rej(new Error('Cannot import torrent ' + torrentId + ': there are multiple files in it'))) |
27 | } | 26 | } |
28 | 27 | ||
29 | torrent.on('done', () => res(join(CONFIG.STORAGE.VIDEOS_DIR, torrent.files[ 0 ].path))) | 28 | torrent.on('done', () => { |
29 | // FIXME: Dirty fix, we need to wait the FS sync but webtorrent does not provide such method | ||
30 | setTimeout(() => res(join(CONFIG.STORAGE.VIDEOS_DIR, torrent.files[ 0 ].name)), 1000) | ||
31 | }) | ||
30 | }) | 32 | }) |
31 | 33 | ||
32 | torrent.on('error', err => rej(err)) | 34 | torrent.on('error', err => rej(err)) |