Skip to content
Snippets Groups Projects
Commit d79f1796 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#663 - ensure settings exist on migration error:

error during migration leads to missing settings (database table still empty) -> this prevents fetch of status --> user stuck in progress indicator forever
parent 68de338a
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ public class MigrationService ...@@ -44,7 +44,7 @@ public class MigrationService
this.transactionRepository = transactionRepository; this.transactionRepository = transactionRepository;
this.templateRepository = templateRepository; this.templateRepository = templateRepository;
this.databaseConfig = databaseConfig; this.databaseConfig = databaseConfig;
this.migrationTask = new MigrationTask(applicationSupportFolder); this.migrationTask = new MigrationTask(applicationSupportFolder, settingsService);
this.scheduler = scheduler; this.scheduler = scheduler;
} }
......
package de.deadlocker8.budgetmaster.migration; package de.deadlocker8.budgetmaster.migration;
import de.deadlocker8.budgetmaster.settings.SettingsService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -27,14 +28,17 @@ public class MigrationTask implements Runnable ...@@ -27,14 +28,17 @@ public class MigrationTask implements Runnable
private final Path applicationSupportFolder; private final Path applicationSupportFolder;
private final SettingsService settingsService;
private MigrationArguments migrationArguments; private MigrationArguments migrationArguments;
private MigrationStatus migrationStatus; private MigrationStatus migrationStatus;
private List<String> collectedStdout; private List<String> collectedStdout;
private List<String> summary; private List<String> summary;
public MigrationTask(Path applicationSupportFolder) public MigrationTask(Path applicationSupportFolder, SettingsService settingsService)
{ {
this.applicationSupportFolder = applicationSupportFolder; this.applicationSupportFolder = applicationSupportFolder;
this.settingsService = settingsService;
this.migrationStatus = MigrationStatus.NOT_RUNNING; this.migrationStatus = MigrationStatus.NOT_RUNNING;
} }
...@@ -72,6 +76,11 @@ public class MigrationTask implements Runnable ...@@ -72,6 +76,11 @@ public class MigrationTask implements Runnable
} }
finally finally
{ {
// if any error happens during migration the settings table might be still empty and lead to errors
// and an infinite progress indicator loop during fetch of the migration status due to SettingsAdvice.class
// Therefore ensure settings exist at this point
settingsService.createDefaultSettingsIfNotExists();
Files.deleteIfExists(migratorPath); Files.deleteIfExists(migratorPath);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment