aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/cache/videos-preview-cache.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-12 17:53:50 +0100
committerChocobozzz <me@florianbigard.com>2017-12-13 16:50:33 +0100
commit3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch)
treee5ca358287fca6ecacce83defcf23af1e8e9f419 /server/lib/cache/videos-preview-cache.ts
parentc893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff)
downloadPeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip
Move models to typescript-sequelize
Diffstat (limited to 'server/lib/cache/videos-preview-cache.ts')
-rw-r--r--server/lib/cache/videos-preview-cache.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index 7f352f361..c5bda8dd8 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -1,11 +1,10 @@
1import * as asyncLRU from 'async-lru' 1import * as asyncLRU from 'async-lru'
2import { join } from 'path'
3import { createWriteStream } from 'fs' 2import { createWriteStream } from 'fs'
4 3import { join } from 'path'
5import { database as db, CONFIG, CACHE } from '../../initializers'
6import { logger, unlinkPromise } from '../../helpers' 4import { logger, unlinkPromise } from '../../helpers'
7import { VideoInstance } from '../../models' 5import { CACHE, CONFIG } from '../../initializers'
8import { fetchRemoteVideoPreview } from '../activitypub/videos' 6import { VideoModel } from '../../models/video/video'
7import { fetchRemoteVideoPreview } from '../activitypub'
9 8
10class VideosPreviewCache { 9class VideosPreviewCache {
11 10
@@ -43,7 +42,7 @@ class VideosPreviewCache {
43 } 42 }
44 43
45 private async loadPreviews (key: string) { 44 private async loadPreviews (key: string) {
46 const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(key) 45 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(key)
47 if (!video) return undefined 46 if (!video) return undefined
48 47
49 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) 48 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
@@ -53,7 +52,7 @@ class VideosPreviewCache {
53 return res 52 return res
54 } 53 }
55 54
56 private saveRemotePreviewAndReturnPath (video: VideoInstance) { 55 private saveRemotePreviewAndReturnPath (video: VideoModel) {
57 const req = fetchRemoteVideoPreview(video) 56 const req = fetchRemoteVideoPreview(video)
58 57
59 return new Promise<string>((res, rej) => { 58 return new Promise<string>((res, rej) => {