]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/cache/videos-preview-cache.ts
Design modals
[github/Chocobozzz/PeerTube.git] / server / lib / cache / videos-preview-cache.ts
index c5bda8dd894e699471bfc50765db882f0c388555..0eb43efcc03dc10c7aab65a929b1e64bfa2f1734 100644 (file)
@@ -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<string>((res, rej) => {
       this.lru.get(key, (err, value) => {
         err ? rej(err) : res(value)
@@ -45,7 +50,7 @@ class VideosPreviewCache {
     const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(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)