Skip to content

Commit 7bc4c63

Browse files
committed
Migration: don't overwrite existing files
1 parent 4bf9f52 commit 7bc4c63

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ See Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building
6161
* Run it with default configuration: `fastfetch`
6262
* 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`
6363
* Find all data that fastfetch detects: `fastfetch -s <module> --format json`
64-
* Get help messages: `fastfetch --help`
64+
* Display help messages: `fastfetch --help`
65+
* Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --mirgrate-config`
6566

6667
## Customization
6768

src/fastfetch.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
481481
{
482482
if (instance.state.configDoc)
483483
{
484-
fputs("Error: existing jsonc config file detected. Aborting\n", stderr);
484+
fputs("Error: existing jsonc config detected. Aborting\n", stderr);
485485
exit(477);
486486
}
487487

@@ -492,6 +492,12 @@ static void parseOption(FFdata* data, const char* key, const char* value)
492492
}
493493
else
494494
ffStrbufSetS(&instance.state.migrateConfigPath, value);
495+
496+
if (ffPathExists(instance.state.migrateConfigPath.chars, FF_PATHTYPE_ANY))
497+
{
498+
fprintf(stderr, "Error: file `%s` exists. Aborting\n", instance.state.migrateConfigPath.chars);
499+
exit(477);
500+
}
495501
}
496502
else if(ffStrEqualsIgnCase(key, "--load-user-config"))
497503
data->loadUserConfig = ffOptionParseBoolean(value);

0 commit comments

Comments
 (0)