diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-25 19:42:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-25 19:42:05 +0200 |
commit | 69fa54a0b21999b4fcafea9223ca37888c30d627 (patch) | |
tree | 9cb92763e273146fdfc8341bda6266c1465f9331 /server/helpers | |
parent | 4a08f6692780fa5147d85126af3089fc7891e436 (diff) | |
download | PeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.tar.gz PeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.tar.zst PeerTube-69fa54a0b21999b4fcafea9223ca37888c30d627.zip |
Dirty webtorrent fix to wait FS sync
Diffstat (limited to 'server/helpers')
-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)) |