1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Refactor video caption/preview caches

This commit is contained in:
Chocobozzz 2019-04-24 09:28:06 +02:00
parent 3acc508440
commit dc85273764
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 10 additions and 24 deletions

View file

@ -1,7 +1,5 @@
import { createWriteStream, remove } from 'fs-extra'
import { remove } from 'fs-extra'
import { logger } from '../../helpers/logger'
import { VideoModel } from '../../models/video/video'
import { fetchRemoteVideoStaticFile } from '../activitypub'
import * as memoizee from 'memoizee'
type GetFilePathResult = { isOwned: boolean, path: string } | undefined
@ -29,16 +27,4 @@ export abstract class AbstractVideoStaticFileCache <T> {
}
})
}
protected saveRemoteVideoFileAndReturnPath (video: VideoModel, remoteStaticPath: string, destPath: string) {
return new Promise<string>((res, rej) => {
const req = fetchRemoteVideoStaticFile(video, remoteStaticPath, rej)
const stream = createWriteStream(destPath)
req.pipe(stream)
.on('error', (err) => rej(err))
.on('finish', () => res(destPath))
})
}
}