mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Add comments federation tests
This commit is contained in:
parent
ae45f988bb
commit
d50acfab69
10 changed files with 136 additions and 57 deletions
10
server/lib/cache/videos-preview-cache.ts
vendored
10
server/lib/cache/videos-preview-cache.ts
vendored
|
@ -52,21 +52,19 @@ class VideosPreviewCache {
|
|||
|
||||
if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
|
||||
|
||||
const res = await this.saveRemotePreviewAndReturnPath(video)
|
||||
|
||||
return res
|
||||
return this.saveRemotePreviewAndReturnPath(video)
|
||||
}
|
||||
|
||||
private saveRemotePreviewAndReturnPath (video: VideoModel) {
|
||||
const req = fetchRemoteVideoPreview(video)
|
||||
|
||||
return new Promise<string>((res, rej) => {
|
||||
const req = fetchRemoteVideoPreview(video, rej)
|
||||
const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName())
|
||||
const stream = createWriteStream(path)
|
||||
|
||||
req.pipe(stream)
|
||||
.on('finish', () => res(path))
|
||||
.on('error', (err) => rej(err))
|
||||
.on('error', (err) => rej(err))
|
||||
.on('finish', () => res(path))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue