import { VideoFileModel } from '../../models/video/video-file'
import { downloadWebTorrentVideo } from '../../helpers/webtorrent'
import { join } from 'path'
-import { rename } from 'fs-extra'
+import { move } from 'fs-extra'
import { getServerActor } from '../../helpers/utils'
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
export class VideosRedundancyScheduler extends AbstractScheduler {
private static instance: AbstractScheduler
- private executing = false
protected schedulerIntervalMs = CONFIG.REDUNDANCY.VIDEOS.CHECK_INTERVAL
super()
}
- async execute () {
- if (this.executing) return
-
- this.executing = true
-
+ protected async internalExecute () {
for (const obj of CONFIG.REDUNDANCY.VIDEOS.STRATEGIES) {
logger.info('Running redundancy scheduler for strategy %s.', obj.strategy)
await this.extendsLocalExpiration()
await this.purgeRemoteExpired()
-
- this.executing = false
}
static get Instance () {
const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file))
- await rename(tmpPath, destPath)
+ await move(tmpPath, destPath)
const createdModel = await VideoRedundancyModel.create({
expiresOn: this.buildNewExpiration(redundancy.minLifetime),