]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/files-cache/videos-preview-cache.ts
Fix E2E tests
[github/Chocobozzz/PeerTube.git] / server / lib / files-cache / videos-preview-cache.ts
index 51146d71843934ec4ce06605fc3d6b8245e9b54d..dd3a84aca60a7c8fe5d0dbf7c6a3676bea57d3aa 100644 (file)
@@ -20,7 +20,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
   }
 
   async getFilePathImpl (filename: string) {
-    const thumbnail = await ThumbnailModel.loadWithVideoByName(filename, ThumbnailType.PREVIEW)
+    const thumbnail = await ThumbnailModel.loadWithVideoByFilename(filename, ThumbnailType.PREVIEW)
     if (!thumbnail) return undefined
 
     if (thumbnail.Video.isOwned()) return { isOwned: true, path: thumbnail.getPath() }
@@ -28,6 +28,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
     return this.loadRemoteFile(thumbnail.Video.uuid)
   }
 
+  // Key is the video UUID
   protected async loadRemoteFile (key: string) {
     const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(key)
     if (!video) return undefined
@@ -38,7 +39,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
     const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename)
 
     const remoteUrl = preview.getFileUrl(video)
-    await doRequestAndSaveToFile({ uri: remoteUrl }, destPath)
+    await doRequestAndSaveToFile(remoteUrl, destPath)
 
     logger.debug('Fetched remote preview %s to %s.', remoteUrl, destPath)