Migration: don't overwrite existing files

This commit is contained in:
李通洲 2023-11-01 11:28:08 +08:00
parent 4bf9f524d9
commit 7bc4c63eb4
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
2 changed files with 9 additions and 2 deletions

View File

@ -61,7 +61,8 @@ See Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building
* Run it with default configuration: `fastfetch`
* Run it with [all supported modules](https://github.com/fastfetch-cli/fastfetch/wiki/Support+Status#available-modules) and find what you interest: `fastfetch -c all.jsonc`
* Find all data that fastfetch detects: `fastfetch -s <module> --format json`
* Get help messages: `fastfetch --help`
* Display help messages: `fastfetch --help`
* Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --mirgrate-config`
## Customization

View File

@ -481,7 +481,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
{
if (instance.state.configDoc)
{
fputs("Error: existing jsonc config file detected. Aborting\n", stderr);
fputs("Error: existing jsonc config detected. Aborting\n", stderr);
exit(477);
}
@ -492,6 +492,12 @@ static void parseOption(FFdata* data, const char* key, const char* value)
}
else
ffStrbufSetS(&instance.state.migrateConfigPath, value);
if (ffPathExists(instance.state.migrateConfigPath.chars, FF_PATHTYPE_ANY))
{
fprintf(stderr, "Error: file `%s` exists. Aborting\n", instance.state.migrateConfigPath.chars);
exit(477);
}
}
else if(ffStrEqualsIgnCase(key, "--load-user-config"))
data->loadUserConfig = ffOptionParseBoolean(value);