diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-05-06 01:18:33 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-05-06 01:18:33 -0400 |
| commit | ab2476b9e051576fb0ddb90f1879d699c1b4ad93 (patch) | |
| tree | af64cf4319455c2451b62c417742f0f4cb64be5c /MediaBrowser.Server.Implementations/Library/Validators | |
| parent | c27e4154717f61b2cafd57bdbe590c2b1875b136 (diff) | |
| parent | 5a496a1fc8d9ee2e728d6f712ae6bdf4862183f1 (diff) | |
Merge pull request #1710 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Validators')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs index c122d64d3..00dc8e6a1 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Model.Logging; using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -35,25 +34,20 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// <returns>Task.</returns> public async Task Run(IProgress<double> progress, CancellationToken cancellationToken) { - var items = _libraryManager.RootFolder.GetRecursiveChildren() - .SelectMany(i => i.Studios) - .DistinctNames() - .ToList(); + var items = _libraryManager.GetItemList(new InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(Studio).Name } + + }).ToList(); var numComplete = 0; var count = items.Count; - var validIds = new List<Guid>(); - - foreach (var name in items) + foreach (var item in items) { try { - var itemByName = _libraryManager.GetStudio(name); - - validIds.Add(itemByName.Id); - - await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); + await item.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { @@ -62,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.ErrorException("Error refreshing {0}", ex, name); + _logger.ErrorException("Error refreshing {0}", ex, item.Name); } numComplete++; @@ -73,28 +67,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators progress.Report(percent); } - var allIds = _libraryManager.GetItemIds(new InternalItemsQuery - { - IncludeItemTypes = new[] { typeof(Studio).Name } - }); - - var invalidIds = allIds - .Except(validIds) - .ToList(); - - foreach (var id in invalidIds) - { - cancellationToken.ThrowIfCancellationRequested(); - - var item = _libraryManager.GetItemById(id); - - await _libraryManager.DeleteItem(item, new DeleteOptions - { - DeleteFileLocation = false - - }).ConfigureAwait(false); - } - progress.Report(100); } } |
