🐛 bug: allow `auto-gen-key` to also recreate the file and fix permissions
parent
3054991c5e
commit
02b6955a50
|
@ -81,17 +81,24 @@ async fn main () -> Result <(), anyhow::Error> {
|
|||
|
||||
let path = opt.config_path.clone ().unwrap_or_else (|| PathBuf::from ("./config/ptth_server.toml"));
|
||||
|
||||
let config_file: ConfigFile = match load_toml::load (&path) {
|
||||
Err (ptth_server::errors::LoadTomlError::Io (_)) => if opt.auto_gen_key {
|
||||
gen_and_save_key (&path)?;
|
||||
|
||||
load_toml::load (&path)?
|
||||
let config_file: ConfigFile = if opt.auto_gen_key {
|
||||
// If we're in autonomous mode, try harder to fix things
|
||||
|
||||
match load_toml::load (&path) {
|
||||
Err (_) => {
|
||||
gen_and_save_key (&path)?;
|
||||
|
||||
load_toml::load (&path)?
|
||||
},
|
||||
Ok (x) => x,
|
||||
}
|
||||
}
|
||||
else {
|
||||
match load_toml::load (&path) {
|
||||
Err (ptth_server::errors::LoadTomlError::Io (_)) => bail! ("API key not provided in config file and auto-gen-key not provided"),
|
||||
Ok (x) => x,
|
||||
Err (e) => return Err (e.into ()),
|
||||
}
|
||||
else {
|
||||
bail! ("API key not provided in config file and auto-gen-key not provided");
|
||||
},
|
||||
Ok (x) => x,
|
||||
Err (e) => return Err (e.into ()),
|
||||
};
|
||||
|
||||
let config_file = ptth_server::ConfigFile {
|
||||
|
|
Loading…
Reference in New Issue