aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/cache
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/cache')
-rw-r--r--server/lib/cache/videos-preview-cache.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index 0eb43efcc..ea959076d 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -52,21 +52,19 @@ class VideosPreviewCache {
52 52
53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.') 53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
54 54
55 const res = await this.saveRemotePreviewAndReturnPath(video) 55 return this.saveRemotePreviewAndReturnPath(video)
56
57 return res
58 } 56 }
59 57
60 private saveRemotePreviewAndReturnPath (video: VideoModel) { 58 private saveRemotePreviewAndReturnPath (video: VideoModel) {
61 const req = fetchRemoteVideoPreview(video)
62 59
63 return new Promise<string>((res, rej) => { 60 return new Promise<string>((res, rej) => {
61 const req = fetchRemoteVideoPreview(video, rej)
64 const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName()) 62 const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName())
65 const stream = createWriteStream(path) 63 const stream = createWriteStream(path)
66 64
67 req.pipe(stream) 65 req.pipe(stream)
68 .on('finish', () => res(path)) 66 .on('error', (err) => rej(err))
69 .on('error', (err) => rej(err)) 67 .on('finish', () => res(path))
70 }) 68 })
71 } 69 }
72} 70}