Reduce lazy static error logs
This commit is contained in:
parent
a4152bed14
commit
cd25344f74
|
@ -1,4 +1,5 @@
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { logger } from '@server/helpers/logger'
|
||||||
import { doRequestAndSaveToFile } from '@server/helpers/requests'
|
import { doRequestAndSaveToFile } from '@server/helpers/requests'
|
||||||
import { CONFIG } from '../../initializers/config'
|
import { CONFIG } from '../../initializers/config'
|
||||||
import { FILES_CACHE } from '../../initializers/constants'
|
import { FILES_CACHE } from '../../initializers/constants'
|
||||||
|
@ -41,9 +42,15 @@ class VideosCaptionCache extends AbstractVideoStaticFileCache <string> {
|
||||||
const remoteUrl = videoCaption.getFileUrl(video)
|
const remoteUrl = videoCaption.getFileUrl(video)
|
||||||
const destPath = join(FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename)
|
const destPath = join(FILES_CACHE.VIDEO_CAPTIONS.DIRECTORY, videoCaption.filename)
|
||||||
|
|
||||||
|
try {
|
||||||
await doRequestAndSaveToFile(remoteUrl, destPath)
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,13 +37,19 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
|
||||||
|
|
||||||
const preview = video.getPreview()
|
const preview = video.getPreview()
|
||||||
const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename)
|
const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename)
|
||||||
|
|
||||||
const remoteUrl = preview.getFileUrl(video)
|
const remoteUrl = preview.getFileUrl(video)
|
||||||
|
|
||||||
|
try {
|
||||||
await doRequestAndSaveToFile(remoteUrl, destPath)
|
await doRequestAndSaveToFile(remoteUrl, destPath)
|
||||||
|
|
||||||
logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath)
|
logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath)
|
||||||
|
|
||||||
return { isOwned: false, path: destPath }
|
return { isOwned: false, path: destPath }
|
||||||
|
} catch (err) {
|
||||||
|
logger.info('Cannot fetch remote preview file %s.', remoteUrl, { err })
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { logger } from '@server/helpers/logger'
|
||||||
import { doRequestAndSaveToFile } from '@server/helpers/requests'
|
import { doRequestAndSaveToFile } from '@server/helpers/requests'
|
||||||
import { VideoFileModel } from '@server/models/video/video-file'
|
import { VideoFileModel } from '@server/models/video/video-file'
|
||||||
|
import { MVideo, MVideoFile } from '@server/types/models'
|
||||||
import { CONFIG } from '../../initializers/config'
|
import { CONFIG } from '../../initializers/config'
|
||||||
import { FILES_CACHE } from '../../initializers/constants'
|
import { FILES_CACHE } from '../../initializers/constants'
|
||||||
import { VideoModel } from '../../models/video/video'
|
import { VideoModel } from '../../models/video/video'
|
||||||
import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
|
import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
|
||||||
import { MVideo, MVideoFile } from '@server/types/models'
|
|
||||||
|
|
||||||
class VideosTorrentCache extends AbstractVideoStaticFileCache <string> {
|
class VideosTorrentCache extends AbstractVideoStaticFileCache <string> {
|
||||||
|
|
||||||
|
@ -46,11 +47,17 @@ class VideosTorrentCache extends AbstractVideoStaticFileCache <string> {
|
||||||
const remoteUrl = file.getRemoteTorrentUrl(video)
|
const remoteUrl = file.getRemoteTorrentUrl(video)
|
||||||
const destPath = join(FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename)
|
const destPath = join(FILES_CACHE.TORRENTS.DIRECTORY, file.torrentFilename)
|
||||||
|
|
||||||
|
try {
|
||||||
await doRequestAndSaveToFile(remoteUrl, destPath)
|
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) {
|
private buildDownloadName (video: MVideo, file: MVideoFile) {
|
||||||
|
|
Loading…
Reference in New Issue