1
0
Fork 0

Fix redundancy max size

This commit is contained in:
Chocobozzz 2021-05-26 09:44:16 +02:00
parent ceb8f32211
commit 53e7f82fe3
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 2 additions and 46 deletions

View file

@ -317,8 +317,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
private async isTooHeavy (candidateToDuplicate: CandidateToDuplicate) {
const maxSize = candidateToDuplicate.redundancy.size
const totalDuplicated = await VideoRedundancyModel.getTotalDuplicated(candidateToDuplicate.redundancy.strategy)
const totalWillDuplicate = totalDuplicated + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists)
const { totalUsed } = await VideoRedundancyModel.getStats(candidateToDuplicate.redundancy.strategy)
const totalWillDuplicate = totalUsed + this.getTotalFileSizes(candidateToDuplicate.files, candidateToDuplicate.streamingPlaylists)
return totalWillDuplicate > maxSize
}

View file

@ -407,50 +407,6 @@ export class VideoRedundancyModel extends Model {
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 () {
const actor = await getServerActor()