diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-30 09:25:17 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-30 09:25:17 +0200 |
commit | cd25344f741e8c97b113b36eb6babc7be490114d (patch) | |
tree | 83742ef011ea3ea66cba7fefbafa593614215e22 | |
parent | a4152bed14427ef91f69e11d1a2cd9745aa74408 (diff) | |
download | PeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.tar.gz PeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.tar.zst PeerTube-cd25344f741e8c97b113b36eb6babc7be490114d.zip |
Reduce lazy static error logs
-rw-r--r-- | server/lib/files-cache/videos-caption-cache.ts | 11 | ||||
-rw-r--r-- | server/lib/files-cache/videos-preview-cache.ts | 14 | ||||
-rw-r--r-- | server/lib/files-cache/videos-torrent-cache.ts | 15 |
3 files changed, 30 insertions, 10 deletions
diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts index 2927c37eb..d21acf4ef 100644 --- a/server/lib/files-cache/videos-caption-cache.ts +++ b/server/lib/files-cache/videos-caption-cache.ts | |||
@@ -1,4 +1,5 @@ | |||
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 { CONFIG } from '../../initializers/config' | 4 | import { CONFIG } from '../../initializers/config' |
4 | import { FILES_CACHE } from '../../initializers/constants' | 5 | import { FILES_CACHE } from '../../initializers/constants' |
@@ -41,9 +42,15 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache <string> { | |||
41 | const remoteUrl = videoCaption.getFileUrl(video) | 42 | const remoteUrl = videoCaption.getFileUrl(video) |
42 | const destPath = join(FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename) | 43 | const destPath = join(FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename) |
43 | 44 | ||
44 | await doRequestAndSaveToFile(remoteUrl, destPath) | 45 | try { |
46 | await doRequestAndSaveToFile(remoteUrl, destPath) | ||
45 | 47 | ||
46 | return { isOwned: false, path: destPath } | 48 | return { isOwned: false, path: destPath } |
49 | } catch (err) { | ||
50 | logger.info('Cannot fetch remote caption file %s.', remoteUrl, { err }) | ||
51 | |||
52 | return undefined | ||
53 | } | ||
47 | } | 54 | } |
48 | } | 55 | } |
49 | 56 | ||
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts index b7a8d6105..48d2cb52c 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> { | |||
37 | 37 | ||
38 | const preview = video.getPreview() | 38 | const preview = video.getPreview() |
39 | const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename) | 39 | const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename) |
40 | |||
41 | const remoteUrl = preview.getFileUrl(video) | 40 | const remoteUrl = preview.getFileUrl(video) |
42 | await doRequestAndSaveToFile(remoteUrl, destPath) | ||
43 | 41 | ||
44 | logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath) | 42 | try { |
43 | await doRequestAndSaveToFile(remoteUrl, destPath) | ||
44 | |||
45 | logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath) | ||
46 | |||
47 | return { isOwned: false, path: destPath } | ||
48 | } catch (err) { | ||
49 | logger.info('Cannot fetch remote preview file %s.', remoteUrl, { err }) | ||
45 | 50 | ||
46 | return { isOwned: false, path: destPath } | 51 | return undefined |
52 | } | ||
47 | } | 53 | } |
48 | } | 54 | } |
49 | 55 | ||
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) { |