From e23efc9a84d7fbb02176c0dfd481664f8b0c2416 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 9 Dec 2013 21:36:24 -0500 Subject: [PATCH] have seasons refresh on series folder changes --- .../Providers/BaseMetadataProvider.cs | 63 +++++++++---------- MediaBrowser.Mono.userprefs | 36 ++--------- .../CollectionFolderImageProvider.cs | 7 ++- .../ImageFromMediaLocationProvider.cs | 15 +++++ .../ImagesByNameProvider.cs | 7 ++- 5 files changed, 59 insertions(+), 69 deletions(-) diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs index 40afe0b544..0acb45f93c 100644 --- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs @@ -325,6 +325,16 @@ namespace MediaBrowser.Controller.Providers return !item.ResolveArgs.IsDirectory; } + protected virtual IEnumerable GetItemsForFileStampComparison(BaseItem item) + { + if (UseParentFileSystemStamp(item) && item.Parent != null) + { + return new[] { item.Parent }; + } + + return new[] { item }; + } + /// /// Gets the item's current file system stamp /// @@ -332,12 +342,7 @@ namespace MediaBrowser.Controller.Providers /// Guid. private Guid GetCurrentFileSystemStamp(BaseItem item) { - if (UseParentFileSystemStamp(item) && item.Parent != null) - { - return GetFileSystemStamp(item.Parent); - } - - return GetFileSystemStamp(item); + return GetFileSystemStamp(GetItemsForFileStampComparison(item)); } private Dictionary _fileStampExtensionsDictionary; @@ -355,43 +360,37 @@ namespace MediaBrowser.Controller.Providers /// /// Gets the file system stamp. /// - /// The item. + /// The items. /// Guid. - protected virtual Guid GetFileSystemStamp(BaseItem item) + protected virtual Guid GetFileSystemStamp(IEnumerable items) { - // If there's no path or the item is a file, there's nothing to do - if (item.LocationType != LocationType.FileSystem) - { - return Guid.Empty; - } + var sb = new StringBuilder(); - ItemResolveArgs resolveArgs; + var extensions = FileStampExtensionsDictionary; + var numExtensions = FilestampExtensions.Length; - try - { - resolveArgs = item.ResolveArgs; - } - catch (IOException ex) + foreach (var item in items) { - Logger.ErrorException("Error determining if path is directory: {0}", ex, item.Path); - throw; + // If there's no path or the item is a file, there's nothing to do + if (item.LocationType == LocationType.FileSystem) + { + var resolveArgs = item.ResolveArgs; + + if (resolveArgs.IsDirectory) + { + // Record the name of each file + // Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order + AddFiles(sb, resolveArgs.FileSystemChildren, extensions, numExtensions); + AddFiles(sb, resolveArgs.MetadataFiles, extensions, numExtensions); + } + } } - if (!resolveArgs.IsDirectory) + if (sb.Length == 0) { return Guid.Empty; } - var sb = new StringBuilder(); - - var extensions = FileStampExtensionsDictionary; - var numExtensions = FilestampExtensions.Length; - - // Record the name of each file - // Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order - AddFiles(sb, resolveArgs.FileSystemChildren, extensions, numExtensions); - AddFiles(sb, resolveArgs.MetadataFiles, extensions, numExtensions); - return sb.ToString().GetMD5(); } diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs index d07dfa4cbf..666ef38acf 100644 --- a/MediaBrowser.Mono.userprefs +++ b/MediaBrowser.Mono.userprefs @@ -1,43 +1,17 @@  - + - + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MediaBrowser.Providers/CollectionFolderImageProvider.cs b/MediaBrowser.Providers/CollectionFolderImageProvider.cs index 45b1b36c26..6c36dbf7e4 100644 --- a/MediaBrowser.Providers/CollectionFolderImageProvider.cs +++ b/MediaBrowser.Providers/CollectionFolderImageProvider.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.IO; +using System.Collections.Generic; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -35,9 +36,9 @@ namespace MediaBrowser.Providers .FirstOrDefault(i => i != null); } - protected override Guid GetFileSystemStamp(BaseItem item) + protected override Guid GetFileSystemStamp(IEnumerable items) { - var files = item.ResolveArgs.PhysicalLocations + var files = items.SelectMany(i => i.ResolveArgs.PhysicalLocations) .Select(i => new DirectoryInfo(i)) .SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly)) .Where(i => diff --git a/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs index 37d39f3d99..65e8afd7ad 100644 --- a/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs +++ b/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs @@ -58,6 +58,21 @@ namespace MediaBrowser.Providers return false; } + protected override IEnumerable GetItemsForFileStampComparison(BaseItem item) + { + var season = item as Season; + if (season != null) + { + var series = season.Series; + if (series != null) + { + return new[] { item, series }; + } + } + + return base.GetItemsForFileStampComparison(item); + } + /// /// Gets the priority. /// diff --git a/MediaBrowser.Providers/ImagesByNameProvider.cs b/MediaBrowser.Providers/ImagesByNameProvider.cs index 5904308234..8c5636580f 100644 --- a/MediaBrowser.Providers/ImagesByNameProvider.cs +++ b/MediaBrowser.Providers/ImagesByNameProvider.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.IO; +using System.Collections.Generic; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -69,9 +70,9 @@ namespace MediaBrowser.Providers return GetImageFromLocation(location, filenameWithoutExtension); } - protected override Guid GetFileSystemStamp(BaseItem item) + protected override Guid GetFileSystemStamp(IEnumerable items) { - var location = GetLocation(item); + var location = GetLocation(items.First()); try {