Merge branch 'release/3.2.0' into develop

This commit is contained in:
Chocobozzz 2021-05-26 13:41:15 +02:00
commit 8ee37c5f38
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 3 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

@ -408,50 +408,6 @@ export class VideoRedundancyModel extends Model<Partial<AttributesOnly<VideoRedu
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()

View File

@ -1009,6 +1009,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
attributes: [ 'id' ],
where: {
isLive: true,
remote: false,
state: VideoState.PUBLISHED
}
}