diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index d5df769a98..7e266a9288 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -54,7 +54,6 @@ namespace MediaBrowser.Controller.Providers CheckCharacters = false, IgnoreProcessingInstructions = true, IgnoreComments = true, - IgnoreWhitespace = true, ValidationType = ValidationType.None }; diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs index b69ece418b..dd03c88ded 100644 --- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs @@ -31,6 +31,12 @@ namespace MediaBrowser.Controller.Providers /// protected readonly Guid Id; + /// + /// The true task result + /// + protected static readonly Task TrueTaskResult = Task.FromResult(true); + protected static readonly Task FalseTaskResult = Task.FromResult(false); + protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(5, 5); /// @@ -207,7 +213,7 @@ namespace MediaBrowser.Controller.Providers return true; } - if (RefreshOnVersionChange && !string.Equals(ProviderVersion, providerInfo.ProviderVersion)) + if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion)) { return true; } @@ -223,7 +229,7 @@ namespace MediaBrowser.Controller.Providers /// true if [has file system stamp changed] [the specified item]; otherwise, false. protected bool HasFileSystemStampChanged(BaseItem item, BaseProviderInfo providerInfo) { - return !string.Equals(GetCurrentFileSystemStamp(item), providerInfo.FileSystemStamp); + return !String.Equals(GetCurrentFileSystemStamp(item), providerInfo.FileSystemStamp); } /// diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs index 465cfec92b..f11ba8f979 100644 --- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs +++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs @@ -52,11 +52,6 @@ namespace MediaBrowser.Controller.Providers } } - /// - /// The true task result - /// - protected static readonly Task TrueTaskResult = Task.FromResult(true); - /// /// Fetches metadata and returns true or false indicating if any work that requires persistence was done /// diff --git a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs index b81e0c51d1..4529e4890b 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs @@ -81,26 +81,22 @@ namespace MediaBrowser.Controller.Providers.Movies /// Task{System.Boolean}. public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { - // Since we don't have anything truly async, and since deserializing can be expensive, create a task to force parallelism - return Task.Run(() => + cancellationToken.ThrowIfCancellationRequested(); + + var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME)); + if (entry.HasValue) { - cancellationToken.ThrowIfCancellationRequested(); - - var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME)); - if (entry.HasValue) - { - // read in our saved meta and pass to processing function - var movieData = JsonSerializer.DeserializeFromFile(entry.Value.Path); + // read in our saved meta and pass to processing function + var movieData = JsonSerializer.DeserializeFromFile(entry.Value.Path); - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); - ProcessMainInfo(item, movieData); + ProcessMainInfo(item, movieData); - SetLastRefreshed(item, DateTime.UtcNow); - return true; - } - return false; - }); + SetLastRefreshed(item, DateTime.UtcNow); + return TrueTaskResult; + } + return FalseTaskResult; } } } diff --git a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs index e89f1a0443..1860f16c2b 100644 --- a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs @@ -92,28 +92,24 @@ namespace MediaBrowser.Controller.Providers.Movies /// Task{System.Boolean}. public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { - return Task.Run(() => - { - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); - try - { - var personInfo = JsonSerializer.DeserializeFromFile(Path.Combine(item.MetaLocation, MetaFileName)); + try + { + var personInfo = JsonSerializer.DeserializeFromFile(Path.Combine(item.MetaLocation, MetaFileName)); - cancellationToken.ThrowIfCancellationRequested(); - - ProcessInfo((Person)item, personInfo); + cancellationToken.ThrowIfCancellationRequested(); - SetLastRefreshed(item, DateTime.UtcNow); - return true; - } - catch (FileNotFoundException) - { - // This is okay - just means we force refreshed and there isn't a json file - return false; - } + ProcessInfo((Person)item, personInfo); - }); + SetLastRefreshed(item, DateTime.UtcNow); + return TrueTaskResult; + } + catch (FileNotFoundException) + { + // This is okay - just means we force refreshed and there isn't a json file + return FalseTaskResult; + } } } } diff --git a/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs b/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs index 6ff6a51829..ce96cd1072 100644 --- a/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs @@ -32,27 +32,24 @@ namespace MediaBrowser.Controller.Providers.Music public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { - return Task.Run(() => - { - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); - var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName)); - if (entry.HasValue) - { - // read in our saved meta and pass to processing function - var data = JsonSerializer.DeserializeFromFile(entry.Value.Path); + var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName)); + if (entry.HasValue) + { + // read in our saved meta and pass to processing function + var data = JsonSerializer.DeserializeFromFile(entry.Value.Path); - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); - LastfmHelper.ProcessArtistData(item, data); + LastfmHelper.ProcessArtistData(item, data); - item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid); + item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid); - SetLastRefreshed(item, DateTime.UtcNow); - return true; - } - return false; - }); + SetLastRefreshed(item, DateTime.UtcNow); + return TrueTaskResult; + } + return FalseTaskResult; } public override MetadataProviderPriority Priority diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs index a995f1a476..a5c2f28b71 100644 --- a/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs +++ b/MediaBrowser.Server.Implementations/ScheduledTasks/VideoImagesTask.cs @@ -3,6 +3,7 @@ using MediaBrowser.Common.MediaInfo; using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers.MediaInfo; using MediaBrowser.Model.Entities; @@ -95,33 +96,40 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks /// Task. public async Task Execute(CancellationToken cancellationToken, IProgress progress) { - var items = _libraryManager.RootFolder.RecursiveChildren - .OfType