From a08ae466a2129c1c38f89baeb46de048bc4002bd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 10 Mar 2015 22:49:32 -0400 Subject: [PATCH] update BeforeSave during metadata refresh --- .../Manager/MetadataService.cs | 3 ++- .../Music/AlbumMetadataService.cs | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 8e5fe8c0e..ab9525636 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -163,7 +163,8 @@ namespace MediaBrowser.Providers.Manager } } - updateType = updateType | (await BeforeSave(itemOfType, item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata, updateType).ConfigureAwait(false)); + var beforeSaveResult = await BeforeSave(itemOfType, item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata || refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh, updateType).ConfigureAwait(false); + updateType = updateType | beforeSaveResult; // Save if changes were made, or it's never been saved before if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata) diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index 11348361a..90248e418 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -104,14 +104,15 @@ namespace MediaBrowser.Providers.Music { var updateType = ItemUpdateType.None; - var albumArtists = songs + var artists = songs .SelectMany(i => i.AlbumArtists) .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(i => i) .ToList(); - if (!item.AlbumArtists.SequenceEqual(albumArtists, StringComparer.OrdinalIgnoreCase)) + if (!item.AlbumArtists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) { - item.AlbumArtists = albumArtists; + item.AlbumArtists = artists; updateType = updateType | ItemUpdateType.MetadataEdit; } @@ -122,14 +123,15 @@ namespace MediaBrowser.Providers.Music { var updateType = ItemUpdateType.None; - var currentList = item.Artists.ToList(); - - item.Artists = songs.SelectMany(i => i.Artists) + var artists = songs + .SelectMany(i => i.Artists) .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(i => i) .ToList(); - if (currentList.Count != item.Artists.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Artists.OrderBy(i => i), StringComparer.OrdinalIgnoreCase)) + if (!item.Artists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) { + item.Artists = artists; updateType = updateType | ItemUpdateType.MetadataEdit; }