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.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index c5bda8dd8..28908b186 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -33,7 +33,12 @@ class VideosPreviewCache {
33 }) 33 })
34 } 34 }
35 35
36 getPreviewPath (key: string) { 36 async getPreviewPath (key: string) {
37 const video = await VideoModel.loadByUUID(key)
38 if (!video) return undefined
39
40 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
41
37 return new Promise<string>((res, rej) => { 42 return new Promise<string>((res, rej) => {
38 this.lru.get(key, (err, value) => { 43 this.lru.get(key, (err, value) => {
39 err ? rej(err) : res(value) 44 err ? rej(err) : res(value)
@@ -42,10 +47,10 @@ class VideosPreviewCache {
42 } 47 }
43 48
44 private async loadPreviews (key: string) { 49 private async loadPreviews (key: string) {
45 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(key) 50 const video = await VideoModel.loadByUUID(key)
46 if (!video) return undefined 51 if (!video) return undefined
47 52
48 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) 53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
49 54
50 const res = await this.saveRemotePreviewAndReturnPath(video) 55 const res = await this.saveRemotePreviewAndReturnPath(video)
51 56