diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-08-21 22:59:10 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-08-21 22:59:10 -0400 |
| commit | de133cb8aa2b078ba653ee7c3e1cef4fd16996d6 (patch) | |
| tree | 32921d4b76c387227a5d30f86bc0e1a17a2fd360 /MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs | |
| parent | 4307c67b5e518ef2514740b0a874f5832f31e537 (diff) | |
update search
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs index fe2e6a114..ee06fecdf 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Collections.Generic; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Logging; using System; @@ -42,12 +43,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var numComplete = 0; var count = items.Count; + var validIds = new List<Guid>(); + foreach (var name in items) { try { var itemByName = _libraryManager.GetGameGenre(name); + validIds.Add(itemByName.Id); + await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) @@ -68,6 +73,26 @@ namespace MediaBrowser.Server.Implementations.Library.Validators progress.Report(percent); } + var allIds = _libraryManager.GetItemIds(new InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(GameGenre).Name } + }); + + var invalidIds = allIds + .Except(validIds) + .ToList(); + + foreach (var id in invalidIds) + { + var item = _libraryManager.GetItemById(id); + + await _libraryManager.DeleteItem(item, new DeleteOptions + { + DeleteFileLocation = false + + }).ConfigureAwait(false); + } + progress.Report(100); } } |
