Bläddra i källkod

More logging, mark all migrations as applied if setup wizard is not complete

Vasily 5 år sedan
förälder
incheckning
d4564d8e29
1 ändrade filer med 15 tillägg och 2 borttagningar
  1. 15 2
      Jellyfin.Server/Migrations/MigrationRunner.cs

+ 15 - 2
Jellyfin.Server/Migrations/MigrationRunner.cs

@@ -28,6 +28,17 @@ namespace Jellyfin.Server.Migrations
         {
             var logger = loggerFactory.CreateLogger<MigrationRunner>();
             var migrationOptions = ((IConfigurationManager)host.ServerConfigurationManager).GetConfiguration<MigrationOptions>(MigrationsListStore.StoreKey);
+
+            if (!host.ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
+            {
+                // If startup wizard is not finished, this is a fresh install.
+                // Don't run any migrations, just mark all of them as applied.
+                logger.LogInformation("Marking all known migrations as applied because this is fresh install");
+                migrationOptions.Applied = Migrations.Select(m => m.Name).ToArray();
+                host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
+                return;
+            }
+
             var applied = migrationOptions.Applied.ToList();
 
             for (var i = 0; i < Migrations.Length; i++)
@@ -35,20 +46,22 @@ namespace Jellyfin.Server.Migrations
                 var updater = Migrations[i];
                 if (applied.Contains(updater.Name))
                 {
-                    logger.LogDebug("Skipping migration {0} as it is already applied", updater.Name);
+                    logger.LogDebug("Skipping migration {Name} as it is already applied", updater.Name);
                     continue;
                 }
 
+                logger.LogInformation("Applying migration {Name}", updater.Name);
                 try
                 {
                     updater.Perform(host, logger);
                 }
                 catch (Exception ex)
                 {
-                    logger.LogError(ex, "Cannot apply migration {0}", updater.Name);
+                    logger.LogError(ex, "Cannot apply migration {Name}", updater.Name);
                     continue;
                 }
 
+                logger.LogInformation("Migration {Name} applied successfully", updater.Name);
                 applied.Add(updater.Name);
             }