mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Use async/await in lib and initializers
This commit is contained in:
parent
eb08047657
commit
f5028693a8
21 changed files with 721 additions and 751 deletions
15
server/lib/cache/videos-preview-cache.ts
vendored
15
server/lib/cache/videos-preview-cache.ts
vendored
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue