X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Ffiles-cache%2Fvideos-caption-cache.ts;h=d21acf4ef7fa666c955590675643bb47d3f5c6b9;hb=b7221c1d94e088231ef28b11d95d45d781fbe41c;hp=58e2260b63bff999749ffe75b4fe6bc80a1a01e5;hpb=db4b15f21fbf4e33434e930ffc7fb768cdcf9d42;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts index 58e2260b6..d21acf4ef 100644 --- a/server/lib/files-cache/videos-caption-cache.ts +++ b/server/lib/files-cache/videos-caption-cache.ts @@ -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 { 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(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 + } } }