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.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index fecdca6ef..0fe4d2f78 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -1,7 +1,6 @@
1import * as asyncLRU from 'async-lru' 1import * as asyncLRU from 'async-lru'
2import { join } from 'path' 2import { join } from 'path'
3import { createWriteStream } from 'fs' 3import { createWriteStream } from 'fs'
4import * as Promise from 'bluebird'
5 4
6import { database as db, CONFIG, CACHE } from '../../initializers' 5import { database as db, CONFIG, CACHE } from '../../initializers'
7import { logger, unlinkPromise } from '../../helpers' 6import { logger, unlinkPromise } from '../../helpers'
@@ -43,15 +42,15 @@ class VideosPreviewCache {
43 }) 42 })
44 } 43 }
45 44
46 private loadPreviews (key: string) { 45 private async loadPreviews (key: string) {
47 return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(key) 46 const video = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(key)
48 .then(video => { 47 if (!video) return undefined
49 if (!video) return undefined
50 48
51 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) 49 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
52 50
53 return this.saveRemotePreviewAndReturnPath(video) 51 const res = await this.saveRemotePreviewAndReturnPath(video)
54 }) 52
53 return res
55 } 54 }
56 55
57 private saveRemotePreviewAndReturnPath (video: VideoInstance) { 56 private saveRemotePreviewAndReturnPath (video: VideoInstance) {