mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-18 03:01:09 +01:00
Add config migration process
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import { BackendConfigType, ConfigType } from '../../types/config';
|
||||
import { BackendConfigType } from '../../types/config';
|
||||
import { configExists } from './configExists';
|
||||
import { getFallbackConfig } from './getFallbackConfig';
|
||||
import { migrateConfig } from './migrateConfig';
|
||||
import { readConfig } from './readConfig';
|
||||
|
||||
export const getConfig = (name: string): BackendConfigType => {
|
||||
if (!configExists(name)) return getFallbackConfig();
|
||||
return readConfig(name);
|
||||
// Else if config exists but contains no "schema_version" property
|
||||
// then it is an old config file and we should try to migrate it
|
||||
// to the new format.
|
||||
let config = readConfig(name);
|
||||
if (!config.schemaVersion) {
|
||||
// TODO: Migrate config to new format
|
||||
config = migrateConfig(config);
|
||||
}
|
||||
return config;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user