diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index b921566aa..6df8f1aed 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -292,7 +292,12 @@ namespace MediaBrowser.Controller.Dto { var type = image.Key; - dto.ImageTags[type] = Kernel.Instance.ImageManager.GetImageCacheTag(item, type, image.Value); + var tag = GetImageCacheTag(item, type, image.Value); + + if (tag.HasValue) + { + dto.ImageTags[type] = tag.Value; + } } dto.Id = GetClientItemId(item); @@ -365,7 +370,7 @@ namespace MediaBrowser.Controller.Dto { dto.ParentLogoItemId = GetClientItemId(parentWithLogo); - dto.ParentLogoImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(parentWithLogo, ImageType.Logo, parentWithLogo.GetImage(ImageType.Logo)); + dto.ParentLogoImageTag = GetImageCacheTag(parentWithLogo, ImageType.Logo, parentWithLogo.GetImage(ImageType.Logo)); } } @@ -393,7 +398,7 @@ namespace MediaBrowser.Controller.Dto { dto.CustomRating = item.CustomRating; } - + if (fields.Contains(ItemFields.Taglines)) { dto.Taglines = item.Taglines; @@ -656,7 +661,7 @@ namespace MediaBrowser.Controller.Dto if (!string.IsNullOrEmpty(primaryImagePath)) { - baseItemPerson.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(entity, ImageType.Primary, primaryImagePath); + baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary, primaryImagePath); } } @@ -712,7 +717,7 @@ namespace MediaBrowser.Controller.Dto if (!string.IsNullOrEmpty(primaryImagePath)) { - studioDto.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(entity, ImageType.Primary, primaryImagePath); + studioDto.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary, primaryImagePath); } } @@ -805,7 +810,7 @@ namespace MediaBrowser.Controller.Dto if (!string.IsNullOrEmpty(chapterInfo.ImagePath)) { - dto.ImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Chapter, chapterInfo.ImagePath); + dto.ImageTag = GetImageCacheTag(item, ImageType.Chapter, chapterInfo.ImagePath); } return dto; @@ -838,7 +843,13 @@ namespace MediaBrowser.Controller.Dto if (!string.IsNullOrEmpty(imagePath)) { - info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath); + try + { + info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath); + } + catch (IOException) + { + } } return info; @@ -980,12 +991,11 @@ namespace MediaBrowser.Controller.Dto /// List{System.String}. private List GetBackdropImageTags(BaseItem item) { - if (item.BackdropImagePaths == null) - { - return new List(); - } - - return item.BackdropImagePaths.Select(p => Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Backdrop, p)).ToList(); + return item.BackdropImagePaths + .Select(p => GetImageCacheTag(item, ImageType.Backdrop, p)) + .Where(i => i.HasValue) + .Select(i => i.Value) + .ToList(); } /// @@ -995,12 +1005,24 @@ namespace MediaBrowser.Controller.Dto /// List{Guid}. private List GetScreenshotImageTags(BaseItem item) { - if (item.ScreenshotImagePaths == null) - { - return new List(); - } + return item.ScreenshotImagePaths + .Select(p => GetImageCacheTag(item, ImageType.Screenshot, p)) + .Where(i => i.HasValue) + .Select(i => i.Value) + .ToList(); + } - return item.ScreenshotImagePaths.Select(p => Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Screenshot, p)).ToList(); + private Guid? GetImageCacheTag(BaseItem item, ImageType type, string path) + { + try + { + return Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Screenshot, path); + } + catch (IOException ex) + { + _logger.ErrorException("Error getting {0} image info for {1}", ex, type, path); + return null; + } } } } 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 { diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 0763c63bb..7347bfa8b 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Movies if (boxset != null) { // See if any movies have a collection id already - return boxset.Children.OfType