diff options
| author | JPVenson <github@jpb.email> | 2025-09-12 21:58:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-12 13:58:16 -0600 |
| commit | c02a24e32a7c4ffc4f00620d53911d044b26c9cc (patch) | |
| tree | c821c817a56b4718f6fce4759513dc979d15754e /MediaBrowser.Controller | |
| parent | deee04ae38cf057938f37c1dd7a98d20cf5b65f3 (diff) | |
Fix several Stackoverflows (#14783)
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 34 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 32 |
3 files changed, 44 insertions, 24 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index bb0b26b8e..275fdac2e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -701,19 +701,7 @@ namespace MediaBrowser.Controller.Entities { get { - var customRating = CustomRating; - if (!string.IsNullOrEmpty(customRating)) - { - return customRating; - } - - var parent = DisplayParent; - if (parent is not null) - { - return parent.CustomRatingForComparison; - } - - return null; + return GetCustomRatingForComparision(); } } @@ -791,6 +779,26 @@ namespace MediaBrowser.Controller.Entities /// <value>The remote trailers.</value> public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; } + private string GetCustomRatingForComparision(HashSet<Guid> callstack = null) + { + callstack ??= new(); + var customRating = CustomRating; + if (!string.IsNullOrEmpty(customRating)) + { + return customRating; + } + + callstack.Add(Id); + + var parent = DisplayParent; + if (parent is not null && !callstack.Contains(parent.Id)) + { + return parent.GetCustomRatingForComparision(callstack); + } + + return null; + } + public virtual double GetDefaultPrimaryImageAspectRatio() { return 0; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 06cbcc2e1..082cf39fa 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -568,7 +568,7 @@ namespace MediaBrowser.Controller.Entities if (recursive && child is Folder folder) { - await folder.RefreshMetadataRecursive(folder.Children.ToList(), refreshOptions, true, progress, cancellationToken).ConfigureAwait(false); + await folder.RefreshMetadataRecursive(folder.Children.Except([this, child]).ToList(), refreshOptions, true, progress, cancellationToken).ConfigureAwait(false); } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 04f47b729..1043029c6 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -152,16 +152,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrEmpty(PrimaryVersionId)) - { - var item = LibraryManager.GetItemById(PrimaryVersionId); - if (item is Video video) - { - return video.MediaSourceCount; - } - } - - return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; + return GetMediaSourceCount(); } } @@ -259,6 +250,27 @@ namespace MediaBrowser.Controller.Entities [JsonIgnore] public override MediaType MediaType => MediaType.Video; + private int GetMediaSourceCount(HashSet<Guid> callstack = null) + { + callstack ??= new(); + if (!string.IsNullOrEmpty(PrimaryVersionId)) + { + var item = LibraryManager.GetItemById(PrimaryVersionId); + if (item is Video video) + { + if (callstack.Contains(video.Id)) + { + return video.LinkedAlternateVersions.Length + video.LocalAlternateVersions.Length + 1; + } + + callstack.Add(video.Id); + return video.GetMediaSourceCount(callstack); + } + } + + return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; + } + public override List<string> GetUserDataKeys() { var list = base.GetUserDataKeys(); |
