diff options
Diffstat (limited to 'server/lib/files-cache/videos-torrent-cache.ts')
-rw-r--r-- | server/lib/files-cache/videos-torrent-cache.ts | 15 |
1 files changed, 11 insertions, 4 deletions
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 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { logger } from '@server/helpers/logger' | ||
2 | import { doRequestAndSaveToFile } from '@server/helpers/requests' | 3 | import { doRequestAndSaveToFile } from '@server/helpers/requests' |
3 | import { VideoFileModel } from '@server/models/video/video-file' | 4 | import { VideoFileModel } from '@server/models/video/video-file' |
5 | import { MVideo, MVideoFile } from '@server/types/models' | ||
4 | import { CONFIG } from '../../initializers/config' | 6 | import { CONFIG } from '../../initializers/config' |
5 | import { FILES_CACHE } from '../../initializers/constants' | 7 | import { FILES_CACHE } from '../../initializers/constants' |
6 | import { VideoModel } from '../../models/video/video' | 8 | import { VideoModel } from '../../models/video/video' |
7 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 9 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
8 | import { MVideo, MVideoFile } from '@server/types/models' | ||
9 | 10 | ||
10 | class VideosTorrentCache extends AbstractVideoStaticFileCache <string> { | 11 | class VideosTorrentCache extends AbstractVideoStaticFileCache <string> { |
11 | 12 | ||
@@ -46,11 +47,17 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache <string> { | |||
46 | const remoteUrl = file.getRemoteTorrentUrl(video) | 47 | const remoteUrl = file.getRemoteTorrentUrl(video) |
47 | const destPath = join(FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename) | 48 | const destPath = join(FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename) |
48 | 49 | ||
49 | await doRequestAndSaveToFile(remoteUrl, destPath) | 50 | try { |
51 | await doRequestAndSaveToFile(remoteUrl, destPath) | ||
50 | 52 | ||
51 | const downloadName = this.buildDownloadName(video, file) | 53 | const downloadName = this.buildDownloadName(video, file) |
52 | 54 | ||
53 | return { isOwned: false, path: destPath, downloadName } | 55 | return { isOwned: false, path: destPath, downloadName } |
56 | } catch (err) { | ||
57 | logger.info('Cannot fetch remote torrent file %s.', remoteUrl, { err }) | ||
58 | |||
59 | return undefined | ||
60 | } | ||
54 | } | 61 | } |
55 | 62 | ||
56 | private buildDownloadName (video: MVideo, file: MVideoFile) { | 63 | private buildDownloadName (video: MVideo, file: MVideoFile) { |