|
|
|
@ -153,7 +153,7 @@ async fn get_folder_contents(url_tail: &str, config: &Config) -> Result<String, |
|
|
|
|
|
|
|
|
|
async fn publicise_it(path: &str, config: &Config) -> Result<bool, Box<dyn std::error::Error>> { |
|
|
|
|
debug!("[publicise_it] Entering function..."); |
|
|
|
|
let base_url = Url::parse(config.paths.root.as_str())?;
|
|
|
|
|
let base_url = Url::parse(config.paths.root.as_str())?; |
|
|
|
|
let url = base_url.join("ocs/v2.php/apps/files_sharing/api/v1/shares")?; |
|
|
|
|
let method = reqwest::Method::POST; |
|
|
|
|
let client = reqwest::Client::new(); |
|
|
|
@ -226,25 +226,26 @@ async fn traverse(mut result: Multistatus, config: &Config) -> Result<bool, Box< |
|
|
|
|
|
|
|
|
|
#[tokio::main] |
|
|
|
|
async fn main() -> std::io::Result<()> { |
|
|
|
|
|
|
|
|
|
env_logger::Builder::from_env(Env::default()).init(); |
|
|
|
|
println!("Publicise it!\n\n"); |
|
|
|
|
|
|
|
|
|
let mut config = init().unwrap(); |
|
|
|
|
if config.credentials.password == None { |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
debug!("[main] {:?}", &config); |
|
|
|
|
|
|
|
|
|
let full_path = &(String::from("/remote.php/dav/files/") + &config.credentials.username + "/" + &config.paths.target); |
|
|
|
|
let folder_contents: String = |
|
|
|
|
get_folder_contents(full_path, &config) |
|
|
|
|
.await |
|
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
let result: Multistatus = from_str(&folder_contents).unwrap(); |
|
|
|
|
debug!("[main] {:?}", result); |
|
|
|
|
|
|
|
|
|
let _ = traverse(result, &config).await.unwrap(); |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|