diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-24 09:28:06 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:26:21 +0200 |
commit | dc8527376482293c87fc6f30027d626f58a1197b (patch) | |
tree | 688625c5ab1619c3235f808a22bed0501c670a62 /server/lib/files-cache/abstract-video-static-file-cache.ts | |
parent | 3acc50844047a37698f0618fa235c138e386a053 (diff) | |
download | PeerTube-dc8527376482293c87fc6f30027d626f58a1197b.tar.gz PeerTube-dc8527376482293c87fc6f30027d626f58a1197b.tar.zst PeerTube-dc8527376482293c87fc6f30027d626f58a1197b.zip |
Refactor video caption/preview caches
Diffstat (limited to 'server/lib/files-cache/abstract-video-static-file-cache.ts')
-rw-r--r-- | server/lib/files-cache/abstract-video-static-file-cache.ts | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/server/lib/files-cache/abstract-video-static-file-cache.ts b/server/lib/files-cache/abstract-video-static-file-cache.ts index 84ed74c98..1908cfb06 100644 --- a/server/lib/files-cache/abstract-video-static-file-cache.ts +++ b/server/lib/files-cache/abstract-video-static-file-cache.ts | |||
@@ -1,7 +1,5 @@ | |||
1 | import { createWriteStream, remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
3 | import { VideoModel } from '../../models/video/video' | ||
4 | import { fetchRemoteVideoStaticFile } from '../activitypub' | ||
5 | import * as memoizee from 'memoizee' | 3 | import * as memoizee from 'memoizee' |
6 | 4 | ||
7 | type GetFilePathResult = { isOwned: boolean, path: string } | undefined | 5 | type GetFilePathResult = { isOwned: boolean, path: string } | undefined |
@@ -29,16 +27,4 @@ export abstract class AbstractVideoStaticFileCache <T> { | |||
29 | } | 27 | } |
30 | }) | 28 | }) |
31 | } | 29 | } |
32 | |||
33 | protected saveRemoteVideoFileAndReturnPath (video: VideoModel, remoteStaticPath: string, destPath: string) { | ||
34 | return new Promise<string>((res, rej) => { | ||
35 | const req = fetchRemoteVideoStaticFile(video, remoteStaticPath, rej) | ||
36 | |||
37 | const stream = createWriteStream(destPath) | ||
38 | |||
39 | req.pipe(stream) | ||
40 | .on('error', (err) => rej(err)) | ||
41 | .on('finish', () => res(destPath)) | ||
42 | }) | ||
43 | } | ||
44 | } | 30 | } |