diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-27 20:03:37 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-27 20:03:37 +0100 |
commit | d50acfab69ce9e05b272dea6c4d34d52960ba14c (patch) | |
tree | 55ce8b70777603b772d2cecb96cd71aac9ccfb9c /server/lib/cache | |
parent | ae45f988bb5ea32152cca02a282d02599dbb633b (diff) | |
download | PeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.tar.gz PeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.tar.zst PeerTube-d50acfab69ce9e05b272dea6c4d34d52960ba14c.zip |
Add comments federation tests
Diffstat (limited to 'server/lib/cache')
-rw-r--r-- | server/lib/cache/videos-preview-cache.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts index 0eb43efcc..ea959076d 100644 --- a/server/lib/cache/videos-preview-cache.ts +++ b/server/lib/cache/videos-preview-cache.ts | |||
@@ -52,21 +52,19 @@ class VideosPreviewCache { | |||
52 | 52 | ||
53 | if (video.isOwned()) throw new Error('Cannot load preview of owned video.') | 53 | if (video.isOwned()) throw new Error('Cannot load preview of owned video.') |
54 | 54 | ||
55 | const res = await this.saveRemotePreviewAndReturnPath(video) | 55 | return this.saveRemotePreviewAndReturnPath(video) |
56 | |||
57 | return res | ||
58 | } | 56 | } |
59 | 57 | ||
60 | private saveRemotePreviewAndReturnPath (video: VideoModel) { | 58 | private saveRemotePreviewAndReturnPath (video: VideoModel) { |
61 | const req = fetchRemoteVideoPreview(video) | ||
62 | 59 | ||
63 | return new Promise<string>((res, rej) => { | 60 | return new Promise<string>((res, rej) => { |
61 | const req = fetchRemoteVideoPreview(video, rej) | ||
64 | const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName()) | 62 | const path = join(CACHE.DIRECTORIES.PREVIEWS, video.getPreviewName()) |
65 | const stream = createWriteStream(path) | 63 | const stream = createWriteStream(path) |
66 | 64 | ||
67 | req.pipe(stream) | 65 | req.pipe(stream) |
68 | .on('finish', () => res(path)) | 66 | .on('error', (err) => rej(err)) |
69 | .on('error', (err) => rej(err)) | 67 | .on('finish', () => res(path)) |
70 | }) | 68 | }) |
71 | } | 69 | } |
72 | } | 70 | } |