aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-25 19:42:05 +0200
committerChocobozzz <me@florianbigard.com>2018-09-25 19:42:05 +0200
commit69fa54a0b21999b4fcafea9223ca37888c30d627 (patch)
tree9cb92763e273146fdfc8341bda6266c1465f9331 /server
parent4a08f6692780fa5147d85126af3089fc7891e436 (diff)
downloadPeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.tar.gz
PeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.tar.zst
PeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.zip
Dirty webtorrent fix to wait FS sync
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))