瀏覽代碼

Removed duplicated code

JPVenson 6 月之前
父節點
當前提交
3b8e177ba8
共有 1 個文件被更改,包括 4 次插入12 次删除
  1. 4 12
      Jellyfin.Server.Implementations/Item/PeopleRepository.cs

+ 4 - 12
Jellyfin.Server.Implementations/Item/PeopleRepository.cs

@@ -70,6 +70,10 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
                 context.Peoples.Add(personEntity);
                 context.Peoples.Add(personEntity);
                 existingEntity = personEntity;
                 existingEntity = personEntity;
             }
             }
+            else
+            {
+                context.Peoples.Attach(personEntity).State = EntityState.Modified;
+            }
 
 
             context.PeopleBaseItemMap.Add(new PeopleBaseItemMap()
             context.PeopleBaseItemMap.Add(new PeopleBaseItemMap()
             {
             {
@@ -83,18 +87,6 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
             });
             });
         }
         }
 
 
-        foreach (var person in people.Select(Map))
-        {
-            if (context.Peoples.Any(f => f.Id == person.Id))
-            {
-                context.Peoples.Attach(person).State = EntityState.Modified;
-            }
-            else
-            {
-                context.Peoples.Add(person);
-            }
-        }
-
         context.SaveChanges();
         context.SaveChanges();
         transaction.Commit();
         transaction.Commit();
     }
     }