diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
commit | 62689b942b71cd1dd0d050c6ed05f884a0b325c2 (patch) | |
tree | c45c35d35d7a3e32621fba06edc63646930c8efd /server/helpers/webtorrent.ts | |
parent | 84b6dbcc6e8654f39ec798905e1151ba915cd1aa (diff) | |
download | PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.gz PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.zst PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.zip |
Correctly migrate to fs-extra
Diffstat (limited to 'server/helpers/webtorrent.ts')
-rw-r--r-- | server/helpers/webtorrent.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 1c0d00d70..1c0cc7058 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { logger } from './logger' | 1 | import { logger } from './logger' |
2 | import { generateVideoTmpPath } from './utils' | 2 | import { generateVideoTmpPath } from './utils' |
3 | import * as WebTorrent from 'webtorrent' | 3 | import * as WebTorrent from 'webtorrent' |
4 | import { createWriteStream } from 'fs-extra' | 4 | import { createWriteStream, remove } from 'fs-extra' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { unlinkPromise } from './core-utils' | ||
8 | 7 | ||
9 | function downloadWebTorrentVideo (target: { magnetUri: string, torrentName: string }) { | 8 | function downloadWebTorrentVideo (target: { magnetUri: string, torrentName: string }) { |
10 | const id = target.magnetUri || target.torrentName | 9 | const id = target.magnetUri || target.torrentName |
@@ -29,11 +28,11 @@ function downloadWebTorrentVideo (target: { magnetUri: string, torrentName: stri | |||
29 | if (err) return rej(err) | 28 | if (err) return rej(err) |
30 | 29 | ||
31 | if (target.torrentName) { | 30 | if (target.torrentName) { |
32 | unlinkPromise(torrentId) | 31 | remove(torrentId) |
33 | .catch(err => logger.error('Cannot remove torrent %s in webtorrent download.', torrentId, { err })) | 32 | .catch(err => logger.error('Cannot remove torrent %s in webtorrent download.', torrentId, { err })) |
34 | } | 33 | } |
35 | 34 | ||
36 | unlinkPromise(join(CONFIG.STORAGE.VIDEOS_DIR, file.name)) | 35 | remove(join(CONFIG.STORAGE.VIDEOS_DIR, file.name)) |
37 | .catch(err => logger.error('Cannot remove torrent file %s in webtorrent download.', file.name, { err })) | 36 | .catch(err => logger.error('Cannot remove torrent file %s in webtorrent download.', file.name, { err })) |
38 | 37 | ||
39 | res(path) | 38 | res(path) |