Fix redundancy with videos already duplicated with another instance
This commit is contained in:
parent
8b917537af
commit
46f8d69b4e
3 changed files with 6 additions and 3 deletions
|
@ -109,7 +109,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
const serverActor = await getServerActor()
|
const serverActor = await getServerActor()
|
||||||
|
|
||||||
for (const file of filesToDuplicate) {
|
for (const file of filesToDuplicate) {
|
||||||
const existing = await VideoRedundancyModel.loadByFileId(file.id)
|
const existing = await VideoRedundancyModel.loadLocalByFileId(file.id)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
await this.extendsExpirationOf(existing, redundancy.minLifetime)
|
await this.extendsExpirationOf(existing, redundancy.minLifetime)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ const videoRedundancyGetValidator = [
|
||||||
if (!videoFile) return res.status(404).json({ error: 'Video file not found.' })
|
if (!videoFile) return res.status(404).json({ error: 'Video file not found.' })
|
||||||
res.locals.videoFile = videoFile
|
res.locals.videoFile = videoFile
|
||||||
|
|
||||||
const videoRedundancy = await VideoRedundancyModel.loadByFileId(videoFile.id)
|
const videoRedundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id)
|
||||||
if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' })
|
if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' })
|
||||||
res.locals.videoRedundancy = videoRedundancy
|
res.locals.videoRedundancy = videoRedundancy
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,12 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
|
||||||
return instance.VideoFile.Video.removeFile(instance.VideoFile)
|
return instance.VideoFile.Video.removeFile(instance.VideoFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadByFileId (videoFileId: number) {
|
static async loadLocalByFileId (videoFileId: number) {
|
||||||
|
const actor = await getServerActor()
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
|
actorId: actor.id,
|
||||||
videoFileId
|
videoFileId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue