Correctly delete files on failed import

pull/1156/head
Chocobozzz 2018-10-01 10:44:16 +02:00
parent 26649b4215
commit e95e0463d8
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import { federateVideoIfNeeded } from '../../activitypub'
import { VideoModel } from '../../../models/video/video'
import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
import { getSecureTorrentName } from '../../../helpers/utils'
import { rename, stat } from 'fs-extra'
import { remove, rename, stat } from 'fs-extra'
type VideoImportYoutubeDLPayload = {
type: 'youtube-dl'
@ -209,7 +209,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
} catch (err) {
try {
// if (tempVideoPath) await unlinkPromise(tempVideoPath)
if (tempVideoPath) await remove(tempVideoPath)
} catch (errUnlink) {
logger.warn('Cannot cleanup files after a video import error.', { err: errUnlink })
}