]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/youtube-dl/youtube-dl-wrapper.ts
Remove contributors list from /about/peertube
[github/Chocobozzz/PeerTube.git] / server / helpers / youtube-dl / youtube-dl-wrapper.ts
index 6960fbae4ec4dbf01b2a7908b54a29ce759f499c..6442c1e855b2106a0e2685d7be8bdf81b0e52183 100644 (file)
@@ -73,12 +73,11 @@ class YoutubeDLWrapper {
     // Leave empty the extension, youtube-dl will add it
     const pathWithoutExtension = generateVideoImportTmpPath(this.url, '')
 
-    let timer: NodeJS.Timeout
-
     logger.info('Importing youtubeDL video %s to %s', this.url, pathWithoutExtension, lTags())
 
     const youtubeDL = await YoutubeDLCLI.safeGet()
 
+    let timer: NodeJS.Timeout
     const timeoutPromise = new Promise<string>((_, rej) => {
       timer = setTimeout(() => rej(new Error('YoutubeDL download timeout.')), timeout)
     })
@@ -99,11 +98,14 @@ class YoutubeDLWrapper {
       })
 
     return Promise.race([ downloadPromise, timeoutPromise ])
-      .catch(async err => {
-        const path = await this.guessVideoPathWithExtension(pathWithoutExtension, fileExt)
-
-        remove(path)
-          .catch(err => logger.error('Cannot remove file in youtubeDL timeout.', { err, ...lTags() }))
+      .catch(err => {
+        this.guessVideoPathWithExtension(pathWithoutExtension, fileExt)
+          .then(path => {
+            logger.debug('Error in youtube-dl import, deleting file %s.', path, { err, ...lTags() })
+
+            return remove(path)
+          })
+          .catch(innerErr => logger.error('Cannot remove file in youtubeDL timeout.', { innerErr, ...lTags() }))
 
         throw err
       })