import { VideoModel } from '../../models/video/video'
import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
import { CONFIG } from '../../initializers/config'
+import { fetchRemoteVideoStaticFile } from '../activitypub'
class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
const video = await VideoModel.loadByUUIDWithFile(videoUUID)
if (!video) return undefined
- if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreview().filename)
+ if (video.isOwned()) return { isOwned: true, path: video.getPreview().getPath() }
return this.loadRemoteFile(videoUUID)
}
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)
+ await fetchRemoteVideoStaticFile(video, remoteStaticPath, destPath)
+
+ return { isOwned: false, path: destPath }
}
}