]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/files-cache/videos-preview-cache.ts
Process remaining segment hashes on live ending
[github/Chocobozzz/PeerTube.git] / server / lib / files-cache / videos-preview-cache.ts
index 3da6bb1388c5bdf1361c50181357f48316725e9c..d0d4fc5b551f4b780aaf86d034624c1b6bacd370 100644 (file)
@@ -1,9 +1,8 @@
 import { join } from 'path'
-import { FILES_CACHE, STATIC_PATHS } from '../../initializers/constants'
+import { FILES_CACHE } from '../../initializers/constants'
 import { VideoModel } from '../../models/video/video'
 import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
-import { CONFIG } from '../../initializers/config'
-import { fetchRemoteVideoStaticFile } from '../activitypub'
+import { doRequestAndSaveToFile } from '@server/helpers/requests'
 
 class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
 
@@ -32,11 +31,11 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
 
     if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.')
 
-    // FIXME: use URL
-    const remoteStaticPath = join(STATIC_PATHS.PREVIEWS, video.getPreview().filename)
-    const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, video.getPreview().filename)
+    const preview = video.getPreview()
+    const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename)
 
-    await fetchRemoteVideoStaticFile(video, remoteStaticPath, destPath)
+    const remoteUrl = preview.getFileUrl(video)
+    await doRequestAndSaveToFile({ uri: remoteUrl }, destPath)
 
     return { isOwned: false, path: destPath }
   }