diff options
Diffstat (limited to 'server/lib/cache')
-rw-r--r-- | server/lib/cache/videos-preview-cache.ts | 15 |
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 @@ | |||
1 | import * as asyncLRU from 'async-lru' | 1 | import * as asyncLRU from 'async-lru' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { createWriteStream } from 'fs' | 3 | import { createWriteStream } from 'fs' |
4 | import * as Promise from 'bluebird' | ||
5 | 4 | ||
6 | import { database as db, CONFIG, CACHE } from '../../initializers' | 5 | import { database as db, CONFIG, CACHE } from '../../initializers' |
7 | import { logger, unlinkPromise } from '../../helpers' | 6 | import { 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) { |