diff options
| author | hatharry <hatharry@hotmail.com> | 2016-08-29 01:27:43 +1200 |
|---|---|---|
| committer | hatharry <hatharry@hotmail.com> | 2016-08-29 01:27:43 +1200 |
| commit | cabf2cdc1be4c06714ac6bcf835a19d2f652a6e2 (patch) | |
| tree | d375b8a41e9fd40a2569ceea6b02e4f8237db797 /MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs | |
| parent | e564b54686029a90595e1bb4277f87490763e183 (diff) | |
| parent | c974641a352685b2e6595dd7b291843c8e6364ac (diff) | |
Merge branch 'dev' of https://github.com/hatharry/Emby.git
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs index 5c43f2e13..d90b9615b 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var peopleOptions = _config.Configuration.PeopleMetadataOptions; - var people = _libraryManager.GetAllPeople(); + var people = _libraryManager.GetPeople(new InternalPeopleQuery()); var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); @@ -112,8 +112,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators } var numComplete = 0; - var validIds = new List<Guid>(); - + + _logger.Debug("Will refresh {0} people", dict.Count); + + var numPeople = dict.Count; + foreach (var person in dict) { cancellationToken.ThrowIfCancellationRequested(); @@ -122,8 +125,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var item = _libraryManager.GetPerson(person.Key); - validIds.Add(item.Id); - var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview); var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30; @@ -138,7 +139,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var options = new MetadataRefreshOptions(_fileSystem) { MetadataRefreshMode = person.Value ? defaultMetadataRefreshMode : MetadataRefreshMode.ValidationOnly, - ImageRefreshMode = person.Value ? imageRefreshMode : ImageRefreshMode.ValidationOnly + ImageRefreshMode = person.Value ? imageRefreshMode : ImageRefreshMode.ValidationOnly, + ForceSave = performFullRefresh }; await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false); @@ -155,36 +157,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators // Update progress numComplete++; double percent = numComplete; - percent /= people.Count; + percent /= numPeople; progress.Report(100 * percent); } - var allIds = _libraryManager.GetItemIds(new InternalItemsQuery - { - IncludeItemTypes = new[] { typeof(Person).Name } - }); - - var invalidIds = allIds - .Except(validIds) - .ToList(); - - foreach (var id in invalidIds) - { - cancellationToken.ThrowIfCancellationRequested(); - - var item = _libraryManager.GetItemById(id); - - if (item != null) - { - await _libraryManager.DeleteItem(item, new DeleteOptions - { - DeleteFileLocation = false - - }).ConfigureAwait(false); - } - } - progress.Report(100); _logger.Info("People validation complete"); |
