diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-18 20:37:01 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-18 20:37:01 -0400 |
| commit | 8136647a0a22588947544647aa748746d75a31c6 (patch) | |
| tree | 4511eb6bef2bb49fd8c6322eb8f96545594d87d0 /MediaBrowser.Server.Implementations/Library | |
| parent | 5b93895c149cf4be5147c017fa24ded7024f4217 (diff) | |
changed ActualChildren to IEnumerable
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs | 16 |
2 files changed, 19 insertions, 8 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 9b78f3980..27d6953d7 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -341,7 +341,7 @@ namespace MediaBrowser.Server.Implementations.Library items.Add(RootFolder); - // Need to use DistinctBy Id because there could be multiple instances with the same id + // Need to use Distinct because there could be multiple instances with the same id // due to sharing the default library var userRootFolders = _userManager.Users.Select(i => i.RootFolder) .Distinct() @@ -357,9 +357,14 @@ namespace MediaBrowser.Server.Implementations.Library items.AddRange(userFolders); - var disctinctItems = items.DistinctBy(i => i.Id).ToList(); + var dictionary = new ConcurrentDictionary<Guid, BaseItem>(); - return new ConcurrentDictionary<Guid, BaseItem>(disctinctItems.ToDictionary(i => i.Id)); + foreach (var item in items) + { + dictionary[item.Id] = item; + } + + return dictionary; } /// <summary> diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs index e3faea071..767df9c79 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -72,6 +72,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var numComplete = 0; + var userLibraries = _userManager.Users + .Select(i => new Tuple<Guid, IHasArtist[]>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToArray())) + .ToArray(); + + var numArtists = allArtists.Count; + foreach (var artist in allArtists) { cancellationToken.ThrowIfCancellationRequested(); @@ -106,14 +112,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators // Populate counts of items //SetItemCounts(artist, null, allItems.OfType<IHasArtist>()); - foreach (var user in _userManager.Users.ToArray()) + foreach (var lib in userLibraries) { - SetItemCounts(artist, user.Id, user.RootFolder.GetRecursiveChildren(user).OfType<IHasArtist>().ToArray()); + SetItemCounts(artist, lib.Item1, lib.Item2); } numComplete++; double percent = numComplete; - percent /= allArtists.Length; + percent /= numArtists; percent *= 20; progress.Report(80 + percent); @@ -180,7 +186,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// <param name="cancellationToken">The cancellation token.</param> /// <param name="progress">The progress.</param> /// <returns>Task{Artist[]}.</returns> - private async Task<Artist[]> GetAllArtists(IEnumerable<Audio> allSongs, CancellationToken cancellationToken, IProgress<double> progress) + private async Task<ConcurrentBag<Artist>> GetAllArtists(IEnumerable<Audio> allSongs, CancellationToken cancellationToken, IProgress<double> progress) { var allArtists = allSongs .SelectMany(i => @@ -251,7 +257,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators await Task.WhenAll(tasks).ConfigureAwait(false); - return returnArtists.ToArray(); + return returnArtists; } /// <summary> |
