diff options
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) |