Skip to content

Commit 77a36f9

Browse files
authored
fix(job): resolve edge case issue with season availability updates (#1483)
Ensure media availability updates correctly for shows marked as UNKNOWN and yet having AVAILABLE or PARTIALLY_AVAILABLE seasons
1 parent f773e0f commit 77a36f9

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

server/lib/availabilitySync.ts

+32-16
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,34 @@ class AvailabilitySync {
404404
});
405405
}
406406

407+
if (
408+
!showExists &&
409+
(media.status === MediaStatus.AVAILABLE ||
410+
media.status === MediaStatus.PARTIALLY_AVAILABLE ||
411+
media.seasons.some(
412+
(season) => season.status === MediaStatus.AVAILABLE
413+
) ||
414+
media.seasons.some(
415+
(season) => season.status === MediaStatus.PARTIALLY_AVAILABLE
416+
))
417+
) {
418+
await this.mediaUpdater(media, false, mediaServerType);
419+
}
420+
421+
if (
422+
!showExists4k &&
423+
(media.status4k === MediaStatus.AVAILABLE ||
424+
media.status4k === MediaStatus.PARTIALLY_AVAILABLE ||
425+
media.seasons.some(
426+
(season) => season.status4k === MediaStatus.AVAILABLE
427+
) ||
428+
media.seasons.some(
429+
(season) => season.status4k === MediaStatus.PARTIALLY_AVAILABLE
430+
))
431+
) {
432+
await this.mediaUpdater(media, true, mediaServerType);
433+
}
434+
407435
// TODO: Figure out how to run seasonUpdater for each season
408436

409437
if ([...finalSeasons.values()].includes(false)) {
@@ -423,22 +451,6 @@ class AvailabilitySync {
423451
mediaServerType
424452
);
425453
}
426-
427-
if (
428-
!showExists &&
429-
(media.status === MediaStatus.AVAILABLE ||
430-
media.status === MediaStatus.PARTIALLY_AVAILABLE)
431-
) {
432-
await this.mediaUpdater(media, false, mediaServerType);
433-
}
434-
435-
if (
436-
!showExists4k &&
437-
(media.status4k === MediaStatus.AVAILABLE ||
438-
media.status4k === MediaStatus.PARTIALLY_AVAILABLE)
439-
) {
440-
await this.mediaUpdater(media, true, mediaServerType);
441-
}
442454
}
443455
}
444456
} catch (ex) {
@@ -466,6 +478,10 @@ class AvailabilitySync {
466478
{ status: MediaStatus.PARTIALLY_AVAILABLE },
467479
{ status4k: MediaStatus.AVAILABLE },
468480
{ status4k: MediaStatus.PARTIALLY_AVAILABLE },
481+
{ seasons: { status: MediaStatus.AVAILABLE } },
482+
{ seasons: { status: MediaStatus.PARTIALLY_AVAILABLE } },
483+
{ seasons: { status4k: MediaStatus.AVAILABLE } },
484+
{ seasons: { status4k: MediaStatus.PARTIALLY_AVAILABLE } },
469485
];
470486

471487
let mediaPage: Media[];

0 commit comments

Comments
 (0)