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:
parent
3acc508440
commit
dc85273764
4 changed files with 10 additions and 24 deletions
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue