소스 검색

remove people refresh retry

Luke Pulverenti 9 년 전
부모
커밋
39245133f8

+ 2 - 0
MediaBrowser.Controller/Entities/InternalPeopleQuery.cs

@@ -11,11 +11,13 @@ namespace MediaBrowser.Controller.Entities
         public int? MaxListOrder { get; set; }
         public Guid AppearsInItemId { get; set; }
         public string NameContains { get; set; }
+        public SourceType[] SourceTypes { get; set; }
 
         public InternalPeopleQuery()
         {
             PersonTypes = new List<string>();
             ExcludePersonTypes = new List<string>();
+            SourceTypes = new SourceType[] { };
         }
     }
 }

+ 0 - 6
MediaBrowser.Controller/Library/ILibraryManager.cs

@@ -474,12 +474,6 @@ namespace MediaBrowser.Controller.Library
         /// <returns>List&lt;Person&gt;.</returns>
         List<Person> GetPeopleItems(InternalPeopleQuery query);
 
-        /// <summary>
-        /// Gets all people names.
-        /// </summary>
-        /// <returns>List&lt;System.String&gt;.</returns>
-        List<PersonInfo> GetAllPeople();
-
         /// <summary>
         /// Updates the people.
         /// </summary>

+ 0 - 7
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -2605,13 +2605,6 @@ namespace MediaBrowser.Server.Implementations.Library
             return ItemRepository.GetPeopleNames(query);
         }
 
-        public List<PersonInfo> GetAllPeople()
-        {
-            return GetPeople(new InternalPeopleQuery())
-                .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
-                .ToList();
-        }
-
         public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
         {
             if (!item.SupportsPeople)

+ 1 - 28
MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs

@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Logging;
 using System;
@@ -43,16 +42,12 @@ 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)
@@ -73,28 +68,6 @@ 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)
-            {
-                cancellationToken.ThrowIfCancellationRequested();
-                
-                var item = _libraryManager.GetItemById(id);
-
-                await _libraryManager.DeleteItem(item, new DeleteOptions
-                {
-                    DeleteFileLocation = false
-
-                }).ConfigureAwait(false);
-            }
-
             progress.Report(100);
         }
     }

+ 1 - 28
MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs

@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Logging;
@@ -44,16 +43,12 @@ 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.GetGenre(name);
 
-                    validIds.Add(itemByName.Id);
-
                     await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
                 }
                 catch (OperationCanceledException)
@@ -74,28 +69,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
                 progress.Report(percent);
             }
 
-            var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
-            {
-                IncludeItemTypes = new[] { typeof(Genre).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);
         }
     }

+ 1 - 29
MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs

@@ -1,6 +1,4 @@
-using System.Collections.Generic;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Logging;
 using System;
@@ -44,16 +42,12 @@ 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.GetMusicGenre(name);
 
-                    validIds.Add(itemByName.Id);
-
                     await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
                 }
                 catch (OperationCanceledException)
@@ -74,28 +68,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
                 progress.Report(percent);
             }
 
-            var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
-            {
-                IncludeItemTypes = new[] { typeof(MusicGenre).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);
         }
     }

+ 6 - 31
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,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
             }
 
             var numComplete = 0;
-            var validIds = new List<Guid>();
-            
+
+            _logger.Debug("Will refresh {0} people", dict.Count);
+
             foreach (var person in dict)
             {
                 cancellationToken.ThrowIfCancellationRequested();
@@ -122,10 +123,9 @@ 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;
+                    var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 90;
+                    performFullRefresh = false;
 
                     var defaultMetadataRefreshMode = performFullRefresh
                         ? MetadataRefreshMode.FullRefresh
@@ -160,31 +160,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
                 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");

+ 0 - 4
MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs

@@ -42,16 +42,12 @@ 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.GetStudio(name);
 
-                    validIds.Add(itemByName.Id);
-
                     await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
                 }
                 catch (OperationCanceledException)

+ 5 - 0
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -3776,6 +3776,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 whereClauses.Add("Name like @NameContains");
                 cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains + "%";
             }
+            if (query.SourceTypes.Length == 1)
+            {
+                whereClauses.Add("(select sourcetype from typedbaseitems where guid=ItemId) = @SourceTypes");
+                cmd.Parameters.Add(cmd, "@SourceTypes", DbType.String).Value = query.SourceTypes[0].ToString();
+            }
 
             return whereClauses;
         }