mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-27 19:20:39 -06:00
Merge branch 'release/3.2.0' into develop
This commit is contained in:
commit
8ee37c5f38
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
||||
|
@ -1009,6 +1009,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
||||
attributes: [ 'id' ],
|
||||
where: {
|
||||
isLive: true,
|
||||
remote: false,
|
||||
state: VideoState.PUBLISHED
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user