diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 4 | ||||
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 44 |
2 files changed, 2 insertions, 46 deletions
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 9e2667416..59b55cccc 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -317,8 +317,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
317 | private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) { | 317 | private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) { |
318 | const maxSize = candidateToDuplicate.redundancy.size | 318 | const maxSize = candidateToDuplicate.redundancy.size |
319 | 319 | ||
320 | const totalDuplicated = await VideoRedundancyModel.getTotalDuplicated(candidateToDuplicate.redundancy.strategy) | 320 | const { totalUsed } = await VideoRedundancyModel.getStats(candidateToDuplicate.redundancy.strategy) |
321 | const totalWillDuplicate = totalDuplicated + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists) | 321 | const totalWillDuplicate = totalUsed + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists) |
322 | 322 | ||
323 | return totalWillDuplicate > maxSize | 323 | return totalWillDuplicate > maxSize |
324 | } | 324 | } |
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 53ebadeaf..a61c3578c 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -407,50 +407,6 @@ export class VideoRedundancyModel extends Model { | |||
407 | return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query) | 407 | return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query) |
408 | } | 408 | } |
409 | 409 | ||
410 | static async getTotalDuplicated (strategy: VideoRedundancyStrategy) { | ||
411 | const actor = await getServerActor() | ||
412 | const redundancyInclude = { | ||
413 | attributes: [], | ||
414 | model: VideoRedundancyModel, | ||
415 | required: true, | ||
416 | where: { | ||
417 | actorId: actor.id, | ||
418 | strategy | ||
419 | } | ||
420 | } | ||
421 | |||
422 | const queryFiles: FindOptions = { | ||
423 | include: [ redundancyInclude ] | ||
424 | } | ||
425 | |||
426 | const queryStreamingPlaylists: FindOptions = { | ||
427 | include: [ | ||
428 | { | ||
429 | attributes: [], | ||
430 | model: VideoModel.unscoped(), | ||
431 | required: true, | ||
432 | include: [ | ||
433 | { | ||
434 | required: true, | ||
435 | attributes: [], | ||
436 | model: VideoStreamingPlaylistModel.unscoped(), | ||
437 | include: [ | ||
438 | redundancyInclude | ||
439 | ] | ||
440 | } | ||
441 | ] | ||
442 | } | ||
443 | ] | ||
444 | } | ||
445 | |||
446 | return Promise.all([ | ||
447 | VideoFileModel.aggregate('size', 'SUM', queryFiles), | ||
448 | VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists) | ||
449 | ]).then(([ r1, r2 ]) => { | ||
450 | return parseAggregateResult(r1) + parseAggregateResult(r2) | ||
451 | }) | ||
452 | } | ||
453 | |||
454 | static async listLocalExpired () { | 410 | static async listLocalExpired () { |
455 | const actor = await getServerActor() | 411 | const actor = await getServerActor() |
456 | 412 | ||