Panic if password script yields no password (#12)
This would happen, e.g., if the database is locked.
This commit is contained in:
parent
e77b79afae
commit
72062842e7
1 changed files with 5 additions and 4 deletions
|
@ -226,25 +226,26 @@ async fn traverse(mut result: Multistatus, config: &Config) -> Result<bool, Box<
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
env_logger::Builder::from_env(Env::default()).init();
|
env_logger::Builder::from_env(Env::default()).init();
|
||||||
println!("Publicise it!\n\n");
|
println!("Publicise it!\n\n");
|
||||||
|
|
||||||
let mut config = init().unwrap();
|
let mut config = init().unwrap();
|
||||||
if config.credentials.password == None {
|
if config.credentials.password == None {
|
||||||
let output = Command::new(&config.credentials.password_script.as_ref().unwrap()).output().unwrap();
|
let output = Command::new(&config.credentials.password_script.as_ref().unwrap()).output().unwrap();
|
||||||
|
if output.stdout.len() == 0 {
|
||||||
|
panic!("[main] Failed to acquire password from provided script.");
|
||||||
|
}
|
||||||
config.credentials.password = Some(String::from_utf8(output.stdout).unwrap());
|
config.credentials.password = Some(String::from_utf8(output.stdout).unwrap());
|
||||||
}
|
}
|
||||||
debug!("[main] {:?}", &config);
|
debug!("[main] {:?}", &config);
|
||||||
|
|
||||||
let full_path = &(String::from("/remote.php/dav/files/") + &config.credentials.username + "/" + &config.paths.target);
|
let full_path = &(String::from("/remote.php/dav/files/") + &config.credentials.username + "/" + &config.paths.target);
|
||||||
let folder_contents: String =
|
let folder_contents: String =
|
||||||
get_folder_contents(full_path, &config)
|
get_folder_contents(full_path, &config)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let result: Multistatus = from_str(&folder_contents).unwrap();
|
let result: Multistatus = from_str(&folder_contents).unwrap();
|
||||||
debug!("[main] {:?}", result);
|
debug!("[main] {:?}", result);
|
||||||
|
|
||||||
let _ = traverse(result, &config).await.unwrap();
|
let _ = traverse(result, &config).await.unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue