From 1007f242002b77db50e004a5a937395fe60f9289 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Sep 2013 22:08:18 -0400 Subject: reduce task allocations by making IBN api synchronous --- .../Dto/DtoService.cs | 94 +++++++--------- .../Library/LibraryManager.cs | 121 ++++----------------- .../Library/LuceneSearchEngine.cs | 18 +-- .../Library/Validators/ArtistsValidator.cs | 13 ++- .../Library/Validators/GameGenresValidator.cs | 10 +- .../Library/Validators/GenresValidator.cs | 8 +- .../Library/Validators/MusicGenresValidator.cs | 8 +- .../Library/Validators/PeoplePostScanTask.cs | 7 +- .../Library/Validators/StudiosValidator.cs | 8 +- 9 files changed, 99 insertions(+), 188 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 948e9a14a..eda6d9c13 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -38,8 +38,8 @@ namespace MediaBrowser.Server.Implementations.Dto _userManager = userManager; _userDataRepository = userDataRepository; _itemRepo = itemRepo; - } - + } + /// /// Converts a BaseItem to a DTOBaseItem /// @@ -63,16 +63,9 @@ namespace MediaBrowser.Server.Implementations.Dto var dto = new BaseItemDto(); - var tasks = new List(); - - if (fields.Contains(ItemFields.Studios)) - { - tasks.Add(AttachStudios(dto, item)); - } - if (fields.Contains(ItemFields.People)) { - tasks.Add(AttachPeople(dto, item)); + AttachPeople(dto, item); } if (fields.Contains(ItemFields.PrimaryImageAspectRatio)) @@ -98,6 +91,11 @@ namespace MediaBrowser.Server.Implementations.Dto AttachUserSpecificInfo(dto, item, user, fields); } + if (fields.Contains(ItemFields.Studios)) + { + AttachStudios(dto, item); + } + AttachBasicFields(dto, item, owner, fields); if (fields.Contains(ItemFields.SoundtrackIds)) @@ -116,12 +114,6 @@ namespace MediaBrowser.Server.Implementations.Dto } } - // Make sure all the tasks we kicked off have completed. - if (tasks.Count > 0) - { - await Task.WhenAll(tasks).ConfigureAwait(false); - } - return dto; } @@ -425,15 +417,15 @@ namespace MediaBrowser.Server.Implementations.Dto _logger.ErrorException("Error getting {0} image info for {1}", ex, type, path); return null; } - } - + } + /// /// Attaches People DTO's to a DTOBaseItem /// /// The dto. /// The item. /// Task. - private async Task AttachPeople(BaseItemDto dto, BaseItem item) + private void AttachPeople(BaseItemDto dto, BaseItem item) { // Ordering by person type to ensure actors and artists are at the front. // This is taking advantage of the fact that they both begin with A @@ -443,24 +435,20 @@ namespace MediaBrowser.Server.Implementations.Dto // Attach People by transforming them into BaseItemPerson (DTO) dto.People = new BaseItemPerson[people.Count]; - var entities = await Task.WhenAll(people.Select(p => p.Name) + var dictionary = people.Select(p => p.Name) .Distinct(StringComparer.OrdinalIgnoreCase).Select(c => - Task.Run(async () => + { + try + { + return _libraryManager.GetPerson(c); + } + catch (IOException ex) { - try - { - return await _libraryManager.GetPerson(c).ConfigureAwait(false); - } - catch (IOException ex) - { - _logger.ErrorException("Error getting person {0}", ex, c); - return null; - } - }) - - )).ConfigureAwait(false); - - var dictionary = entities.Where(i => i != null) + _logger.ErrorException("Error getting person {0}", ex, c); + return null; + } + + }).Where(i => i != null) .DistinctBy(i => i.Name) .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); @@ -497,32 +485,26 @@ namespace MediaBrowser.Server.Implementations.Dto /// The dto. /// The item. /// Task. - private async Task AttachStudios(BaseItemDto dto, BaseItem item) + private void AttachStudios(BaseItemDto dto, BaseItem item) { var studios = item.Studios.ToList(); dto.Studios = new StudioDto[studios.Count]; - var entities = await Task.WhenAll(studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(c => - - Task.Run(async () => - { - try - { - return await _libraryManager.GetStudio(c).ConfigureAwait(false); - } - catch (IOException ex) - { - _logger.ErrorException("Error getting studio {0}", ex, c); - return null; - } - }) - - )).ConfigureAwait(false); - - var dictionary = entities - .Where(i => i != null) - .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); + var dictionary = studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(name => + { + try + { + return _libraryManager.GetStudio(name); + } + catch (IOException ex) + { + _logger.ErrorException("Error getting studio {0}", ex, name); + return null; + } + }) + .Where(i => i != null) + .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); for (var i = 0; i < studios.Count; i++) { diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 602f81c33..10fc8a586 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -590,144 +590,60 @@ namespace MediaBrowser.Server.Implementations.Library /// Gets a Person /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Person}. - public Task GetPerson(string name, bool allowSlowProviders = false) - { - return GetPerson(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets a Person - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [force creation]. /// Task{Person}. - private Task GetPerson(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Person GetPerson(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.PeoplePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.PeoplePath, name); } /// /// Gets a Studio /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Studio}. - public Task GetStudio(string name, bool allowSlowProviders = false) - { - return GetStudio(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the studio. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. /// Task{Studio}. - internal Task GetStudio(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Studio GetStudio(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.StudioPath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.StudioPath, name); } /// /// Gets a Genre /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Genre}. - public Task GetGenre(string name, bool allowSlowProviders = false) - { - return GetGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. /// Task{Genre}. - internal Task GetGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Genre GetGenre(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.GenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.GenrePath, name); } /// /// Gets the genre. /// /// The name. - /// if set to true [allow slow providers]. /// Task{MusicGenre}. - public Task GetMusicGenre(string name, bool allowSlowProviders = false) + public MusicGenre GetMusicGenre(string name) { - return GetMusicGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the music genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. - /// Task{MusicGenre}. - internal Task GetMusicGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.MusicGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.MusicGenrePath, name); } /// /// Gets the game genre. /// /// The name. - /// if set to true [allow slow providers]. /// Task{GameGenre}. - public Task GetGameGenre(string name, bool allowSlowProviders = false) + public GameGenre GetGameGenre(string name) { - return GetGameGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the game genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. - /// Task{GameGenre}. - internal Task GetGameGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.GameGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.GameGenrePath, name); } /// /// Gets a Genre /// /// The name. - /// if set to true [allow slow providers]. /// Task{Genre}. - public Task GetArtist(string name, bool allowSlowProviders = false) + public Artist GetArtist(string name) { - return GetArtist(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the artist. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [force creation]. - /// Task{Artist}. - internal Task GetArtist(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.ArtistsPath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.ArtistsPath, name); } /// @@ -739,17 +655,16 @@ namespace MediaBrowser.Server.Implementations.Library /// Gets a Year /// /// The value. - /// if set to true [allow slow providers]. /// Task{Year}. /// - public Task GetYear(int value, bool allowSlowProviders = false) + public Year GetYear(int value) { if (value <= 0) { throw new ArgumentOutOfRangeException(); } - return GetItemByName(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture), CancellationToken.None, allowSlowProviders); + return GetItemByName(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture)); } /// @@ -940,7 +855,9 @@ namespace MediaBrowser.Server.Implementations.Library try { - await GetPerson(currentPerson.Name, cancellationToken, true, true).ConfigureAwait(false); + var item = GetPerson(currentPerson.Name); + + await item.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (IOException ex) { @@ -964,6 +881,10 @@ namespace MediaBrowser.Server.Implementations.Library progress.Report(100); _logger.Info("People validation complete"); + + // Bad practice, i know. But we keep a lot in memory, unfortunately. + GC.Collect(2, GCCollectionMode.Forced, true); + GC.Collect(2, GCCollectionMode.Forced, true); } /// diff --git a/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs b/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs index 6b37ee62f..43d0e4db7 100644 --- a/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/LuceneSearchEngine.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Library /// The search term. /// IEnumerable{SearchHintResult}. /// searchTerm - public async Task> GetSearchHints(IEnumerable inputItems, string searchTerm) + public Task> GetSearchHints(IEnumerable inputItems, string searchTerm) { if (string.IsNullOrEmpty(searchTerm)) { @@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var artist = await _libraryManager.GetArtist(item).ConfigureAwait(false); + var artist = _libraryManager.GetArtist(item); hints.Add(new Tuple(artist, index.Item1, index.Item2)); } @@ -169,7 +169,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var genre = await _libraryManager.GetGenre(item).ConfigureAwait(false); + var genre = _libraryManager.GetGenre(item); hints.Add(new Tuple(genre, index.Item1, index.Item2)); } @@ -195,7 +195,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var genre = await _libraryManager.GetMusicGenre(item).ConfigureAwait(false); + var genre = _libraryManager.GetMusicGenre(item); hints.Add(new Tuple(genre, index.Item1, index.Item2)); } @@ -221,7 +221,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var genre = await _libraryManager.GetGameGenre(item).ConfigureAwait(false); + var genre = _libraryManager.GetGameGenre(item); hints.Add(new Tuple(genre, index.Item1, index.Item2)); } @@ -246,7 +246,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var studio = await _libraryManager.GetStudio(item).ConfigureAwait(false); + var studio = _libraryManager.GetStudio(item); hints.Add(new Tuple(studio, index.Item1, index.Item2)); } @@ -272,7 +272,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var person = await _libraryManager.GetPerson(item).ConfigureAwait(false); + var person = _libraryManager.GetPerson(item); hints.Add(new Tuple(person, index.Item1, index.Item2)); } @@ -283,11 +283,13 @@ namespace MediaBrowser.Server.Implementations.Library } } - return hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo + var returnValue = hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo { Item = i.Item1, MatchedTerm = i.Item2 }); + + return Task.FromResult(returnValue); } /// diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs index 54d816cb0..f41a2e60c 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// /// The _library manager /// - private readonly LibraryManager _libraryManager; + private readonly ILibraryManager _libraryManager; /// /// The _user manager @@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The library manager. /// The user manager. /// The logger. - public ArtistsValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger) + public ArtistsValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _userManager = userManager; @@ -65,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var innerProgress = new ActionableProgress(); innerProgress.RegisterAction(pct => progress.Report(pct * .8)); - + var allArtists = await GetAllArtists(allSongs, cancellationToken, innerProgress).ConfigureAwait(false); progress.Report(80); @@ -79,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators foreach (var artist in allArtists) { cancellationToken.ThrowIfCancellationRequested(); - + artist.ValidateImages(); artist.ValidateBackdrops(); @@ -230,8 +230,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators try { - var artistItem = await _libraryManager.GetArtist(currentArtist, cancellationToken, true, true) - .ConfigureAwait(false); + var artistItem = _libraryManager.GetArtist(currentArtist); + + await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false); returnArtists.Add(artistItem); } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs index eba7193e0..eb89210ff 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// /// The _library manager /// - private readonly LibraryManager _libraryManager; + private readonly ILibraryManager _libraryManager; /// /// The _user manager @@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILogger _logger; - public GameGenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GameGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _userManager = userManager; @@ -47,8 +47,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Select(i => new Tuple>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType().ToList())) .ToList(); - var allLibraryItems = allItems; - var masterDictionary = new Dictionary>>(StringComparer.OrdinalIgnoreCase); // Populate counts of items @@ -99,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary> counts) { - var itemByName = await _libraryManager.GetGameGenre(name, cancellationToken, true, true).ConfigureAwait(false); + var itemByName = _libraryManager.GetGameGenre(name); foreach (var libraryId in counts.Keys) { @@ -107,6 +105,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators itemByName.UserItemCounts[libraryId] = itemCounts; } + + await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); } private void SetItemCounts(Guid userId, IEnumerable allItems, Dictionary>> masterDictionary) diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs index c605961f7..9a34dd1b0 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// /// The _library manager /// - private readonly LibraryManager _libraryManager; + private readonly ILibraryManager _libraryManager; /// /// The _user manager @@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILogger _logger; - public GenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _userManager = userManager; @@ -102,7 +102,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary> counts) { - var itemByName = await _libraryManager.GetGenre(name, cancellationToken, true, true).ConfigureAwait(false); + var itemByName = _libraryManager.GetGenre(name); foreach (var libraryId in counts.Keys) { @@ -110,6 +110,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators itemByName.UserItemCounts[libraryId] = itemCounts; } + + await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); } private void SetItemCounts(Guid userId, IEnumerable allItems, Dictionary>> masterDictionary) diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs index 9063027ec..1b211d5f4 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// /// The _library manager /// - private readonly LibraryManager _libraryManager; + private readonly ILibraryManager _libraryManager; /// /// The _user manager @@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILogger _logger; - public MusicGenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger) + public MusicGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _userManager = userManager; @@ -102,7 +102,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary> counts) { - var itemByName = await _libraryManager.GetMusicGenre(name, cancellationToken, true, true).ConfigureAwait(false); + var itemByName = _libraryManager.GetMusicGenre(name); foreach (var libraryId in counts.Keys) { @@ -110,6 +110,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators itemByName.UserItemCounts[libraryId] = itemCounts; } + + await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); } private void SetItemCounts(Guid userId, IEnumerable allItems, Dictionary>> masterDictionary) diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs index 708f8bfa4..3c1528d01 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs @@ -41,11 +41,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return RunInternal(progress, cancellationToken); - //return Task.Run(() => RunInternal(progress, cancellationToken)); + return Task.Run(() => RunInternal(progress, cancellationToken)); } - private async Task RunInternal(IProgress progress, CancellationToken cancellationToken) + private void RunInternal(IProgress progress, CancellationToken cancellationToken) { var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList(); @@ -91,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var counts = masterDictionary[name]; - var itemByName = await _libraryManager.GetPerson(name).ConfigureAwait(false); + var itemByName = _libraryManager.GetPerson(name); foreach (var libraryId in counts.Keys) { diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs index 202cd9414..a4d880329 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// /// The _library manager /// - private readonly LibraryManager _libraryManager; + private readonly ILibraryManager _libraryManager; /// /// The _user manager @@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILogger _logger; - public StudiosValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger) + public StudiosValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _userManager = userManager; @@ -99,7 +99,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary> counts) { - var itemByName = await _libraryManager.GetStudio(name, cancellationToken, true, true).ConfigureAwait(false); + var itemByName = _libraryManager.GetStudio(name); foreach (var libraryId in counts.Keys) { @@ -107,6 +107,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators itemByName.UserItemCounts[libraryId] = itemCounts; } + + await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); } private void SetItemCounts(Guid userId, IEnumerable allItems, Dictionary>> masterDictionary) -- cgit v1.2.3