aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/files-cache/videos-torrent-cache.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-30 09:25:17 +0200
committerChocobozzz <me@florianbigard.com>2022-06-30 09:25:17 +0200
commitcd25344f741e8c97b113b36eb6babc7be490114d (patch)
tree83742ef011ea3ea66cba7fefbafa593614215e22 /server/lib/files-cache/videos-torrent-cache.ts
parenta4152bed14427ef91f69e11d1a2cd9745aa74408 (diff)
downloadPeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.tar.gz
PeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.tar.zst
PeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.zip
Reduce lazy static error logs
Diffstat (limited to 'server/lib/files-cache/videos-torrent-cache.ts')
-rw-r--r--server/lib/files-cache/videos-torrent-cache.ts15
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 @@
1import { join } from 'path' 1import { join } from 'path'
2import { logger } from '@server/helpers/logger'
2import { doRequestAndSaveToFile } from '@server/helpers/requests' 3import { doRequestAndSaveToFile } from '@server/helpers/requests'
3import { VideoFileModel } from '@server/models/video/video-file' 4import { VideoFileModel } from '@server/models/video/video-file'
5import { MVideo, MVideoFile } from '@server/types/models'
4import { CONFIG } from '../../initializers/config' 6import { CONFIG } from '../../initializers/config'
5import { FILES_CACHE } from '../../initializers/constants' 7import { FILES_CACHE } from '../../initializers/constants'
6import { VideoModel } from '../../models/video/video' 8import { VideoModel } from '../../models/video/video'
7import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' 9import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
8import { MVideo, MVideoFile } from '@server/types/models'
9 10
10class VideosTorrentCache extends AbstractVideoStaticFileCache <string> { 11class 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) {