From cb0173c4405a10ac770408b4284202c2853fb540 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Mon, 7 Mar 2022 03:38:27 -0500 Subject: [PATCH] [wip] More debugging statements Added more debugging statements because maybe tree is not getting fully traversed --- src/main.rs | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index df18a03..29fe727 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,12 +90,12 @@ pub struct Collection { } async fn get_folder_contents(url_tail: &str, password: &str) -> Result> { - debug!("Entering: get_folder_contents()"); + debug!("[get_folder_contents] Entering function..."); let root_url = Url::parse("https://theadamcooper.com")?; let method = reqwest::Method::from_bytes(b"PROPFIND").unwrap(); let client = reqwest::Client::new(); let url = root_url.join(url_tail)?; - debug!("get_folder_contents: url: {}", url); + debug!("[get_folder_contents] url: {}", url); let body = String::from( r#" @@ -118,18 +118,18 @@ async fn get_folder_contents(url_tail: &str, password: &str) -> Result Result> { - debug!("Entering: publicise()"); + debug!("[publicise_it] Entering function..."); let url = "https://theadamcooper.com/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares"; let method = reqwest::Method::POST; let client = reqwest::Client::new(); let params = [("path", path), ("shareType", "3")]; - debug!("publicise_it: url: {}", url); - debug!("params: {:?}", params); + debug!("[publicise_it] url: {}", url); + debug!("[publicise_it] params: {:?}", params); let response_text = client .request(method, url) .basic_auth("adam", Some(password)) @@ -139,12 +139,12 @@ async fn publicise_it(path: &str, password: &str) -> Result Result> { - debug!("Entering: traverse()"); + debug!("[traverse] Entering function..."); // Initialize the indexed "pointer" let mut current_index: usize = 0; // Initialize the hashmap of visited items (by etag?) @@ -155,14 +155,15 @@ async fn traverse(mut result: Multistatus, password: &str) -> Result Result Result std::io::Result<()> { let password: String = get_password().unwrap().trim().to_string(); let folder_contents: String = - // get_folder_contents("/nextcloud/remote.php/dav/files/adam/test_public/2019_test_public") get_folder_contents("/nextcloud/remote.php/dav/files/adam/test_public", &password) .await .unwrap(); - // debug!("{:?}", folder_contents); let mut result: Multistatus = from_str(&folder_contents).unwrap(); - println!("{:?}", result); + debug!("{:?}", result); let _ = traverse(result, &password).await.unwrap(); Ok(())