mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-17 13:15:03 +02:00
Enforce that --confdir must be a directory (#2051)
* Enforce that when we are using --confdir - the path that is passed in has to be a directory and not a file
This commit is contained in:
parent
a17a667e44
commit
031c82922d
14
src/config.d
14
src/config.d
|
@ -221,6 +221,20 @@ final class Config
|
||||||
mkdirRecurse(configDirName);
|
mkdirRecurse(configDirName);
|
||||||
// Configure the applicable permissions for the folder
|
// Configure the applicable permissions for the folder
|
||||||
configDirName.setAttributes(returnRequiredDirectoryPermisions());
|
configDirName.setAttributes(returnRequiredDirectoryPermisions());
|
||||||
|
} else {
|
||||||
|
// The config path exists
|
||||||
|
// The path that exists must be a directory, not a file
|
||||||
|
if (!isDir(configDirName)) {
|
||||||
|
if (!confdirOption.empty) {
|
||||||
|
// the configuration path was passed in by the user .. user error
|
||||||
|
writeln("ERROR: --confdir entered value is an existing file instead of an existing directory");
|
||||||
|
} else {
|
||||||
|
// other error
|
||||||
|
writeln("ERROR: ~/.config/onedrive is a file rather than a directory");
|
||||||
|
}
|
||||||
|
// Must exit
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// configDirName has a trailing /
|
// configDirName has a trailing /
|
||||||
|
|
|
@ -146,6 +146,9 @@ int main(string[] args)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// confdirOption must be a directory, not a file
|
||||||
|
// - By default ~/.config/onedrive will be used
|
||||||
|
// - If the user is using --confdir , the confdirOption needs to be evaluated when trying to load any file
|
||||||
// load configuration file if available
|
// load configuration file if available
|
||||||
auto cfg = new config.Config(confdirOption);
|
auto cfg = new config.Config(confdirOption);
|
||||||
if (!cfg.initialize()) {
|
if (!cfg.initialize()) {
|
||||||
|
|
Loading…
Reference in a new issue