From da5eaddd91db6077dd5de1657dc9fc97ebc5bf12 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 5 Jul 2013 20:19:44 -0400 Subject: added error handling to image tag generation --- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/Folder.cs | 25 ++++++++++++++++++++--- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 0104db305..05ab35d9a 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -588,7 +588,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the community rating vote count. /// /// The community rating vote count. - public int VoteCount { get; set; } + public int? VoteCount { get; set; } /// /// Gets or sets the run time ticks. diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 8605c7125..549ce06a5 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Entities public List LinkedChildren { get; set; } - protected virtual bool SupportsLinkedChildren + protected virtual bool SupportsShortcutChildren { get { return false; } } @@ -856,6 +856,7 @@ namespace MediaBrowser.Controller.Entities { var parent = System.IO.Path.GetDirectoryName(path); + // Depending on whether the path is local or unc, it may return either null or '\' at the top while (!string.IsNullOrEmpty(parent) && !parent.ToCharArray()[0].Equals(System.IO.Path.DirectorySeparatorChar)) { if (Directory.Exists(parent)) @@ -999,15 +1000,32 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetLinkedChildren() { return LinkedChildren - .Select(i => LibraryManager.RootFolder.FindByPath(i.Path)) + .Select(GetLinkedChild) .Where(i => i != null); } + /// + /// Gets the linked child. + /// + /// The info. + /// BaseItem. + private BaseItem GetLinkedChild(LinkedChild info) + { + var item = LibraryManager.RootFolder.FindByPath(info.Path); + + if (item == null) + { + Logger.Warn("Unable to find linked item at {0}", info.Path); + } + + return item; + } + public override async Task RefreshMetadata(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true, bool resetResolveArgs = true) { var changed = await base.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs).ConfigureAwait(false); - return changed || (SupportsLinkedChildren && LocationType == LocationType.FileSystem && RefreshLinkedChildren()); + return changed || (SupportsShortcutChildren && LocationType == LocationType.FileSystem && RefreshLinkedChildren()); } /// @@ -1059,6 +1077,7 @@ namespace MediaBrowser.Controller.Entities if (!newShortcutLinks.SequenceEqual(currentShortcutLinks)) { + Logger.Info("Shortcut links have changed for {0}", Path); newShortcutLinks.AddRange(currentManualLinks); LinkedChildren = newShortcutLinks; return true; diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 2ee3ccffe..5c99a62f7 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// public class BoxSet : Folder { - protected override bool SupportsLinkedChildren + protected override bool SupportsShortcutChildren { get { -- cgit v1.2.3