[wip] No errors at this point

This commit is contained in:
Adam Cooper 2022-02-16 09:30:46 -05:00
parent 2298b04eec
commit e735a3eeec
2 changed files with 9 additions and 49 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.env .env
Cargo.lock Cargo.lock
scratchpad/ scratchpad/
*.bak

View file

@ -133,20 +133,7 @@ async fn traverse(mut result: Multistatus) {
let mut already_visited: bool; let mut already_visited: bool;
// Initialize the hashmap of visited items (by etag?) // Initialize the hashmap of visited items (by etag?)
let mut visited_items = HashMap::new(); let mut visited_items = HashMap::new();
/* if let Some(prop) = &mut result.response[0].propstat[0].prop {
match result.response[0].propstat[0].prop {
// match result.response.get(0).unwrap().propstat.get(0).unwrap().prop {
Some(prop) => match prop.get_etag {
Some(etag) => {
visited_items.insert(etag, true);
()
}
_ => current_index += 1,
},
_ => current_index += 1,
}
*/
if let Some(prop) = &result.response[0].propstat[0].prop {
if let Some(etag) = &prop.get_etag { if let Some(etag) = &prop.get_etag {
visited_items.insert(etag, true); visited_items.insert(etag, true);
} else { } else {
@ -157,45 +144,17 @@ async fn traverse(mut result: Multistatus) {
} }
// Depth first traversal // Depth first traversal
while current_index < &result.response.len() { while current_index < (&mut result.response).len() {
match &result.response[current_index].propstat[0].prop { match &mut result.response[current_index].propstat[0].prop {
Some(prop) => { Some(prop) => {
match prop.get_etag { match &prop.get_etag {
Some(etag) => { Some(etag) => {
// If result.response[current_index] has not been visited },
if !visited_items.contains_key(&etag) { _ => println!("Something's happening.")
// If item is a collection
match prop.resource_type {
Some(resource_type) => {
if !resource_type.collection.is_empty() {
// Get the contents XML
let folder_contents: String = get_folder_contents(
&result.response[current_index].href,
)
.await
.unwrap();
debug!("{:?}", folder_contents);
// Parse the contents XML into Multistatus
let mut new_result: Multistatus = from_str(&String::from(folder_contents)).unwrap();
// Append the NextcloudResponse vector to result.response
result.response.append(&mut new_result.response);
}
}
_ => current_index += 1,
}
}
// else
// if item is not public, publicise it.
// Add item to visited items hashmap
// Increment current_index by 1
()
}
_ => println!("something's happening"),
} }
} },
_ => println!("something's happening"), _ => println!("Something's happening.")
} }
current_index += 1;
} }
} }