Fix redundancy max size
This commit is contained in:
parent
ceb8f32211
commit
53e7f82fe3
2 changed files with 2 additions and 46 deletions
|
@ -317,8 +317,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) {
|
private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) {
|
||||||
const maxSize = candidateToDuplicate.redundancy.size
|
const maxSize = candidateToDuplicate.redundancy.size
|
||||||
|
|
||||||
const totalDuplicated = await VideoRedundancyModel.getTotalDuplicated(candidateToDuplicate.redundancy.strategy)
|
const { totalUsed } = await VideoRedundancyModel.getStats(candidateToDuplicate.redundancy.strategy)
|
||||||
const totalWillDuplicate = totalDuplicated + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists)
|
const totalWillDuplicate = totalUsed + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists)
|
||||||
|
|
||||||
return totalWillDuplicate > maxSize
|
return totalWillDuplicate > maxSize
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,50 +407,6 @@ export class VideoRedundancyModel extends Model {
|
||||||
return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query)
|
return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getTotalDuplicated (strategy: VideoRedundancyStrategy) {
|
|
||||||
const actor = await getServerActor()
|
|
||||||
const redundancyInclude = {
|
|
||||||
attributes: [],
|
|
||||||
model: VideoRedundancyModel,
|
|
||||||
required: true,
|
|
||||||
where: {
|
|
||||||
actorId: actor.id,
|
|
||||||
strategy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryFiles: FindOptions = {
|
|
||||||
include: [ redundancyInclude ]
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryStreamingPlaylists: FindOptions = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
attributes: [],
|
|
||||||
model: VideoModel.unscoped(),
|
|
||||||
required: true,
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
attributes: [],
|
|
||||||
model: VideoStreamingPlaylistModel.unscoped(),
|
|
||||||
include: [
|
|
||||||
redundancyInclude
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.all([
|
|
||||||
VideoFileModel.aggregate('size', 'SUM', queryFiles),
|
|
||||||
VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists)
|
|
||||||
]).then(([ r1, r2 ]) => {
|
|
||||||
return parseAggregateResult(r1) + parseAggregateResult(r2)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
static async listLocalExpired () {
|
static async listLocalExpired () {
|
||||||
const actor = await getServerActor()
|
const actor = await getServerActor()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue