X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Flib%2Ffiles-cache%2Fvideos-caption-cache.ts;h=d21acf4ef7fa666c955590675643bb47d3f5c6b9;hb=b7221c1d94e088231ef28b11d95d45d781fbe41c;hp=ee0447010b6087c8d0d5f561ca93b085b2cd7ac0;hpb=6302d599cdf98b5a5363a2a1dcdc266447950191;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 ee0447010..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({ 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 + } } }