-
- this.lru.on('evict', (obj: { key: string, value: string }) => {
- remove(obj.value)
- .then(() => logger.debug('%s evicted from %s', obj.value, this.constructor.name))
- })
- }
-
- protected loadFromLRU (key: string) {
- return new Promise<string>((res, rej) => {
- this.lru.get(key, (err, value) => {
- err ? rej(err) : res(value)
- })
- })
- }
-
- 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))
- })