From dc8527376482293c87fc6f30027d626f58a1197b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 24 Apr 2019 09:28:06 +0200 Subject: Refactor video caption/preview caches --- server/lib/activitypub/videos.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 63bb07ec1..4f26cb6be 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -15,7 +15,7 @@ import { sanitizeAndCheckVideoTorrentObject } from '../../helpers/custom-validat import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' import { resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils' import { logger } from '../../helpers/logger' -import { doRequest } from '../../helpers/requests' +import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' import { ACTIVITY_PUB, MIMETYPES, @@ -108,13 +108,11 @@ async function fetchRemoteVideoDescription (video: VideoModel) { return body.description ? body.description : '' } -function fetchRemoteVideoStaticFile (video: VideoModel, path: string, reject: Function) { +function fetchRemoteVideoStaticFile (video: VideoModel, path: string, destPath: string) { const url = buildRemoteBaseUrl(video, path) // We need to provide a callback, if no we could have an uncaught exception - return request.get(url, err => { - if (err) reject(err) - }) + return doRequestAndSaveToFile({ uri: url }, destPath) } function buildRemoteBaseUrl (video: VideoModel, path: string) { -- cgit v1.2.3