From f5028693a896a3076dd286ac0030e3d8f78f5ebf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Oct 2017 16:03:33 +0200 Subject: Use async/await in lib and initializers --- server/lib/cache/videos-preview-cache.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'server/lib/cache') 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 @@ import * as asyncLRU from 'async-lru' import { join } from 'path' import { createWriteStream } from 'fs' -import * as Promise from 'bluebird' import { database as db, CONFIG, CACHE } from '../../initializers' import { logger, unlinkPromise } from '../../helpers' @@ -43,15 +42,15 @@ class VideosPreviewCache { }) } - private loadPreviews (key: string) { - return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(key) - .then(video => { - if (!video) return undefined + private async loadPreviews (key: string) { + const video = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(key) + if (!video) return undefined - if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) + if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) - return this.saveRemotePreviewAndReturnPath(video) - }) + const res = await this.saveRemotePreviewAndReturnPath(video) + + return res } private saveRemotePreviewAndReturnPath (video: VideoInstance) { -- cgit v1.2.3