aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-26 13:41:15 +0200
committerChocobozzz <me@florianbigard.com>2021-05-26 13:41:15 +0200
commit8ee37c5f38b0f9b7e97239197d5590109c163250 (patch)
treed413bfebd188403506372207b26d771714545fbc
parent20213fbd2a366dffc35aa7dddad71323893f8d62 (diff)
parentf49b3231d080767128c80dca7630a1ba9950ed12 (diff)
downloadPeerTube-8ee37c5f38b0f9b7e97239197d5590109c163250.tar.gz
PeerTube-8ee37c5f38b0f9b7e97239197d5590109c163250.tar.zst
PeerTube-8ee37c5f38b0f9b7e97239197d5590109c163250.zip
Merge branch 'release/3.2.0' into develop
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts4
-rw-r--r--server/models/redundancy/video-redundancy.ts44
-rw-r--r--server/models/video/video.ts1
3 files changed, 3 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 ef780c2a4..f7a989691 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -408,50 +408,6 @@ export class VideoRedundancyModel extends Model<Partial<AttributesOnly<VideoRedu
408 return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query) 408 return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query)
409 } 409 }
410 410
411 static async getTotalDuplicated (strategy: VideoRedundancyStrategy) {
412 const actor = await getServerActor()
413 const redundancyInclude = {
414 attributes: [],
415 model: VideoRedundancyModel,
416 required: true,
417 where: {
418 actorId: actor.id,
419 strategy
420 }
421 }
422
423 const queryFiles: FindOptions = {
424 include: [ redundancyInclude ]
425 }
426
427 const queryStreamingPlaylists: FindOptions = {
428 include: [
429 {
430 attributes: [],
431 model: VideoModel.unscoped(),
432 required: true,
433 include: [
434 {
435 required: true,
436 attributes: [],
437 model: VideoStreamingPlaylistModel.unscoped(),
438 include: [
439 redundancyInclude
440 ]
441 }
442 ]
443 }
444 ]
445 }
446
447 return Promise.all([
448 VideoFileModel.aggregate('size', 'SUM', queryFiles),
449 VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists)
450 ]).then(([ r1, r2 ]) => {
451 return parseAggregateResult(r1) + parseAggregateResult(r2)
452 })
453 }
454
455 static async listLocalExpired () { 411 static async listLocalExpired () {
456 const actor = await getServerActor() 412 const actor = await getServerActor()
457 413
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 749ef7197..d4a258187 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1009,6 +1009,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1009 attributes: [ 'id' ], 1009 attributes: [ 'id' ],
1010 where: { 1010 where: {
1011 isLive: true, 1011 isLive: true,
1012 remote: false,
1012 state: VideoState.PUBLISHED 1013 state: VideoState.PUBLISHED
1013 } 1014 }
1014 } 1015 }