From 91da1c035d7b8ee8c7456d62f52dd9e63b5fc59e Mon Sep 17 00:00:00 2001 From: JPVenson Date: Tue, 10 Jun 2025 14:31:01 +0000 Subject: [PATCH 1/2] Fix schema name on backup --- .../FullSystemBackup/BackupService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs index e266d5a3bc..ad8f5f3370 100644 --- a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs +++ b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs @@ -297,7 +297,7 @@ public class BackupService : IBackupService .GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) .Where(e => e.PropertyType.IsAssignableTo(typeof(IQueryable))) .Select(e => (Type: e.PropertyType, ValueFactory: new Func>(() => GetValues((IQueryable)e.GetValue(dbContext)!, e.PropertyType)))), - (Type: typeof(HistoryRow), ValueFactory: new Func>(() => migrations.ToAsyncEnumerable())) + (Type: typeof(IQueryable), ValueFactory: new Func>(() => migrations.ToAsyncEnumerable())) ]; manifest.DatabaseTables = entityTypes.Select(e => e.Type.Name).ToArray(); var transaction = await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false); @@ -308,6 +308,7 @@ public class BackupService : IBackupService foreach (var entityType in entityTypes) { + var schemaName = dbContext.Model.FindEntityType(entityType.Type.GetGenericArguments()[0])!.GetSchemaQualifiedTableName()!; _logger.LogInformation("Begin backup of entity {Table}", entityType.Type.Name); var zipEntry = zipArchive.CreateEntry($"Database\\{entityType.Type.Name}.json"); var entities = 0; From 4a0a45a0459a9921cee88456f2f5bac0dc294f1f Mon Sep 17 00:00:00 2001 From: JPVenson Date: Tue, 10 Jun 2025 14:33:41 +0000 Subject: [PATCH 2/2] Use explicit naming --- .../FullSystemBackup/BackupService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs index ad8f5f3370..d439fcb18b 100644 --- a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs +++ b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs @@ -292,12 +292,12 @@ public class BackupService : IBackupService var historyRepository = dbContext.GetService(); var migrations = await historyRepository.GetAppliedMigrationsAsync().ConfigureAwait(false); - ICollection<(Type Type, Func> ValueFactory)> entityTypes = [ + ICollection<(Type Type, string SourceName, Func> ValueFactory)> entityTypes = [ .. typeof(JellyfinDbContext) .GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) .Where(e => e.PropertyType.IsAssignableTo(typeof(IQueryable))) - .Select(e => (Type: e.PropertyType, ValueFactory: new Func>(() => GetValues((IQueryable)e.GetValue(dbContext)!, e.PropertyType)))), - (Type: typeof(IQueryable), ValueFactory: new Func>(() => migrations.ToAsyncEnumerable())) + .Select(e => (Type: e.PropertyType, dbContext.Model.FindEntityType(e.PropertyType.GetGenericArguments()[0])!.GetSchemaQualifiedTableName()!, ValueFactory: new Func>(() => GetValues((IQueryable)e.GetValue(dbContext)!, e.PropertyType)))), + (Type: typeof(HistoryRow), SourceName: nameof(HistoryRow), ValueFactory: new Func>(() => migrations.ToAsyncEnumerable())) ]; manifest.DatabaseTables = entityTypes.Select(e => e.Type.Name).ToArray(); var transaction = await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false); @@ -308,9 +308,8 @@ public class BackupService : IBackupService foreach (var entityType in entityTypes) { - var schemaName = dbContext.Model.FindEntityType(entityType.Type.GetGenericArguments()[0])!.GetSchemaQualifiedTableName()!; - _logger.LogInformation("Begin backup of entity {Table}", entityType.Type.Name); - var zipEntry = zipArchive.CreateEntry($"Database\\{entityType.Type.Name}.json"); + _logger.LogInformation("Begin backup of entity {Table}", entityType.SourceName); + var zipEntry = zipArchive.CreateEntry($"Database\\{entityType.SourceName}.json"); var entities = 0; var zipEntryStream = zipEntry.Open(); await using (zipEntryStream.ConfigureAwait(false))