mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-02 00:12:24 +00:00
Clear dictionaries when not needed, use set for finding existing base items (#13749)
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
This commit is contained in:
committed by
GitHub
parent
350983e03c
commit
c77a0719c2
@@ -163,7 +163,6 @@ public class MigrateLibraryDb : IMigrationRoutine
|
||||
dbContext.UserData.ExecuteDelete();
|
||||
|
||||
var users = dbContext.Users.AsNoTracking().ToImmutableArray();
|
||||
var oldUserdata = new Dictionary<string, UserData>();
|
||||
|
||||
foreach (var entity in queryResult)
|
||||
{
|
||||
@@ -184,6 +183,8 @@ public class MigrateLibraryDb : IMigrationRoutine
|
||||
dbContext.UserData.Add(userData);
|
||||
}
|
||||
|
||||
users.Clear();
|
||||
legacyBaseItemWithUserKeys.Clear();
|
||||
_logger.LogInformation("Try saving {0} UserData entries.", dbContext.UserData.Local.Count);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
@@ -220,11 +221,12 @@ public class MigrateLibraryDb : IMigrationRoutine
|
||||
dbContext.PeopleBaseItemMap.ExecuteDelete();
|
||||
|
||||
var peopleCache = new Dictionary<string, (People Person, List<PeopleBaseItemMap> Items)>();
|
||||
var baseItemIds = dbContext.BaseItems.Select(b => b.Id).ToHashSet();
|
||||
|
||||
foreach (SqliteDataReader reader in connection.Query(personsQuery))
|
||||
{
|
||||
var itemId = reader.GetGuid(0);
|
||||
if (!dbContext.BaseItems.Any(f => f.Id == itemId))
|
||||
if (!baseItemIds.Contains(itemId))
|
||||
{
|
||||
_logger.LogError("Dont save person {0} because its not in use by any BaseItem", reader.GetString(1));
|
||||
continue;
|
||||
@@ -256,12 +258,16 @@ public class MigrateLibraryDb : IMigrationRoutine
|
||||
});
|
||||
}
|
||||
|
||||
baseItemIds.Clear();
|
||||
|
||||
foreach (var item in peopleCache)
|
||||
{
|
||||
dbContext.Peoples.Add(item.Value.Person);
|
||||
dbContext.PeopleBaseItemMap.AddRange(item.Value.Items.DistinctBy(e => (e.ItemId, e.PeopleId)));
|
||||
}
|
||||
|
||||
peopleCache.Clear();
|
||||
|
||||
_logger.LogInformation("Try saving {0} People entries.", dbContext.MediaStreamInfos.Local.Count);
|
||||
dbContext.SaveChanges();
|
||||
migrationTotalTime += stopwatch.Elapsed;
|
||||
|
||||
Reference in New Issue
Block a user