aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/webtorrent.ts6
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 @@
1import { logger } from './logger' 1import { logger } from './logger'
2import { generateVideoTmpPath } from './utils'
3import * as WebTorrent from 'webtorrent' 2import * as WebTorrent from 'webtorrent'
4import { remove } from 'fs-extra' 3import { remove } from 'fs-extra'
5import { CONFIG } from '../initializers' 4import { 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))