From 8fa5653ad8bebed9a1b2a649e8ea160184d52408 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Dec 2017 11:05:10 +0100 Subject: Add transition on play/loading player --- server/lib/cache/videos-preview-cache.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'server/lib') 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 { }) } - getPreviewPath (key: string) { + async getPreviewPath (key: string) { + const video = await VideoModel.loadByUUID(key) + if (!video) return undefined + + if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) + return new Promise((res, rej) => { this.lru.get(key, (err, value) => { err ? rej(err) : res(value) @@ -42,10 +47,10 @@ class VideosPreviewCache { } private async loadPreviews (key: string) { - const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(key) + const video = await VideoModel.loadByUUID(key) if (!video) return undefined - if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) + if (video.isOwned()) throw new Error('Cannot load preview of owned video.') const res = await this.saveRemotePreviewAndReturnPath(video) -- cgit v1.2.3