]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/files-cache/videos-preview-cache.ts
Create a dedicated table to track video thumbnails
[github/Chocobozzz/PeerTube.git] / server / lib / files-cache / videos-preview-cache.ts
index 6575e1c83a172b121f333bffb4a19bc98a8ba123..fc0d92c78d29383813ac7afc8f7ccd51b6856ffc 100644 (file)
@@ -16,13 +16,13 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
     return this.instance || (this.instance = new this())
   }
 
-  async getFilePath (videoUUID: string) {
+  async getFilePathImpl (videoUUID: string) {
     const video = await VideoModel.loadByUUIDWithFile(videoUUID)
     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.getPreview().filename)
 
-    return this.loadFromLRU(videoUUID)
+    return this.loadRemoteFile(videoUUID)
   }
 
   protected async loadRemoteFile (key: string) {
@@ -31,8 +31,9 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
 
     if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.')
 
-    const remoteStaticPath = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
-    const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, video.getPreviewName())
+    // FIXME: use URL
+    const remoteStaticPath = join(STATIC_PATHS.PREVIEWS, video.getPreview().filename)
+    const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, video.getPreview().filename)
 
     return this.saveRemoteVideoFileAndReturnPath(video, remoteStaticPath, destPath)
   }