]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/files-cache/videos-caption-cache.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / files-cache / videos-caption-cache.ts
index ee0447010b6087c8d0d5f561ca93b085b2cd7ac0..d21acf4ef7fa666c955590675643bb47d3f5c6b9 100644 (file)
@@ -1,4 +1,5 @@
 import { join } from 'path'
+import { logger } from '@server/helpers/logger'
 import { doRequestAndSaveToFile } from '@server/helpers/requests'
 import { CONFIG } from '../../initializers/config'
 import { FILES_CACHE } from '../../initializers/constants'
@@ -35,15 +36,21 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache <string> {
     if (videoCaption.isOwned()) throw new Error('Cannot load remote caption of owned video.')
 
     // Used to fetch the path
-    const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoCaption.videoId)
+    const video = await VideoModel.loadFull(videoCaption.videoId)
     if (!video) return undefined
 
     const remoteUrl = videoCaption.getFileUrl(video)
     const destPath = join(FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename)
 
-    await doRequestAndSaveToFile({ uri: remoteUrl }, destPath)
+    try {
+      await doRequestAndSaveToFile(remoteUrl, destPath)
 
-    return { isOwned: false, path: destPath }
+      return { isOwned: false, path: destPath }
+    } catch (err) {
+      logger.info('Cannot fetch remote caption file %s.', remoteUrl, { err })
+
+      return undefined
+    }
   }
 }