Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Reduce lazy static error logs

Chocobozzzcd25344f741e
diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts
index 2927c37eb0..d21acf4ef7 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'
@@ -41,9 +42,15 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache <string> {
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
+ }
}
}
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts
index b7a8d61056..48d2cb52cf 100644
--- a/server/lib/files-cache/videos-preview-cache.ts
+++ b/server/lib/files-cache/videos-preview-cache.ts
@@ -37,13 +37,19 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
const preview = video.getPreview()
const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename)
-
const remoteUrl = preview.getFileUrl(video)
- await doRequestAndSaveToFile(remoteUrl, destPath)
- logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath)
+ try {
+ await doRequestAndSaveToFile(remoteUrl, destPath)
+
+ logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath)
+
+ return { isOwned: false, path: destPath }
+ } catch (err) {
+ logger.info('Cannot fetch remote preview file %s.', remoteUrl, { err })
- return { isOwned: false, path: destPath }
+ return undefined
+ }
}
}
diff --git a/server/lib/files-cache/videos-torrent-cache.ts b/server/lib/files-cache/videos-torrent-cache.ts
index c8188b79fd..a6bf98dd48 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 <string> {
@@ -46,11 +47,17 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache <string> {
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) {