-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from unipept/fix/wrong-default-config-path
Fix wrong default config path
- Loading branch information
Showing
8 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* For each version upgrade of the application that requires changes to the existing configuration, a new migrator | ||
* that adheres to this interface can be implemented. This migrator will then be executed upon first opening a new | ||
* version of the application. | ||
*/ | ||
export default interface ApplicationMigration { | ||
/** | ||
* This method is called when the application is updated from one version to the next. All changes to the | ||
* configuration of the application that apply to this specific version upgrade should be applied here. | ||
*/ | ||
upgrade(): Promise<void>; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/logic/application/ApplicationMigrationPreviousToV200alpha1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ApplicationMigration from "@/logic/application/ApplicationMigration"; | ||
import ConfigurationManager from "@/logic/configuration/ConfigurationManager"; | ||
import { app } from "@electron/remote"; | ||
|
||
/** | ||
* The default path of the application that's used for storing custom databases changed in version 2.0.0-alpha.1 of | ||
* the application and needs to be reset here. | ||
*/ | ||
export default class ApplicationMigrationPreviousToV200alpha1 implements ApplicationMigration { | ||
public async upgrade(): Promise<void> { | ||
// Reset the configuration back to the default value. | ||
const configManager = new ConfigurationManager(app); | ||
const defaultConfig = await configManager.getDefaultConfiguration(); | ||
await configManager.writeConfiguration(defaultConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ApplicationMigration from "@/logic/application/ApplicationMigration"; | ||
import ConfigurationManager from "@/logic/configuration/ConfigurationManager"; | ||
import ApplicationMigrationPreviousToV200alpha1 from "@/logic/application/ApplicationMigrationPreviousToV200alpha1"; | ||
|
||
export default class ApplicationMigrator { | ||
public async runMigrations(): Promise<void> { | ||
const configManager = new ConfigurationManager(); | ||
const config = await configManager.readConfiguration(); | ||
|
||
// This key was only introduced in v2.0.0-alpha.1 of the application. If it's not present or invalid, we need | ||
// to run the corresponding migration. | ||
if (!config.configurationAppVersion) { | ||
const migration = new ApplicationMigrationPreviousToV200alpha1(); | ||
await migration.upgrade(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters