X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Ffiles-cache%2Fvideos-torrent-cache.ts;h=a6bf98dd48daaa8b5a12faad5dac088591a55dd0;hb=2c015b54192f2080f756c424173bac2bd53e7ca9;hp=c8188b79fddcf622c88d4f978663523a8618e09c;hpb=4fae2b1f300c1f027629569817262f60873a663a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/files-cache/videos-torrent-cache.ts b/server/lib/files-cache/videos-torrent-cache.ts index c8188b79f..a6bf98dd4 100644 --- a/server/lib/files-cache/videos-torrent-cache.ts +++ b/server/lib/files-cache/videos-torrent-cache.ts @@ -1,11 +1,12 @@ import { join } from 'path' +import { logger } from '@server/helpers/logger' import { doRequestAndSaveToFile } from '@server/helpers/requests' import { VideoFileModel } from '@server/models/video/video-file' +import { MVideo, MVideoFile } from '@server/types/models' import { CONFIG } from '../../initializers/config' import { FILES_CACHE } from '../../initializers/constants' import { VideoModel } from '../../models/video/video' import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' -import { MVideo, MVideoFile } from '@server/types/models' class VideosTorrentCache extends AbstractVideoStaticFileCache { @@ -46,11 +47,17 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache { const remoteUrl = file.getRemoteTorrentUrl(video) const destPath = join(FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename) - await doRequestAndSaveToFile(remoteUrl, destPath) + try { + await doRequestAndSaveToFile(remoteUrl, destPath) - const downloadName = this.buildDownloadName(video, file) + const downloadName = this.buildDownloadName(video, file) - return { isOwned: false, path: destPath, downloadName } + return { isOwned: false, path: destPath, downloadName } + } catch (err) { + logger.info('Cannot fetch remote torrent file %s.', remoteUrl, { err }) + + return undefined + } } private buildDownloadName (video: MVideo, file: MVideoFile) {