[wip] Committing now when down to one error
Committing now when down to one error, and before zapping a bunch of ampersands.
This commit is contained in:
parent
3b69ca58cd
commit
1c8e868afd
1 changed files with 12 additions and 12 deletions
24
src/main.rs
24
src/main.rs
|
@ -126,17 +126,17 @@ async fn get_folder_contents(url_tail: &String) -> Result<String, Box<dyn std::e
|
|||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn traverse(mut queue: Vec<NextcloudResponse>) {
|
||||
async fn traverse(result: &Multistatus) {
|
||||
debug!("Entering: traverse()");
|
||||
// Initialize the indexed "pointer"
|
||||
let mut current_index: usize = 0;
|
||||
let mut already_visited: bool;
|
||||
// Initialize the hashmap of visited items (by etag?)
|
||||
let mut visited_items = HashMap::new();
|
||||
// match queue[0].propstat[0].prop {
|
||||
match queue.into_iter().nth(0).unwrap()
|
||||
// match result.response[0].propstat[0].prop {
|
||||
match result.response.into_iter().nth(0).unwrap()
|
||||
.propstat.into_iter().nth(0).unwrap().prop {
|
||||
Some(prop) => match &prop.get_etag {
|
||||
Some(prop) => match prop.get_etag {
|
||||
Some(etag) => {
|
||||
visited_items.insert(etag, true);
|
||||
()
|
||||
|
@ -146,12 +146,12 @@ async fn traverse(mut queue: Vec<NextcloudResponse>) {
|
|||
_ => current_index += 1,
|
||||
}
|
||||
// Depth first traversal
|
||||
while !queue.is_empty() {
|
||||
match &queue[current_index].propstat[0].prop {
|
||||
while !result.response.is_empty() {
|
||||
match &result.response[current_index].propstat[0].prop {
|
||||
Some(prop) => {
|
||||
match &prop.get_etag {
|
||||
Some(etag) => {
|
||||
// If queue[current_index] has not been visited
|
||||
// If result.response[current_index] has not been visited
|
||||
if !visited_items.contains_key(etag) {
|
||||
// If item is a collection
|
||||
// TODO(amcooper): Again, replace unwrap with the match implementation,
|
||||
|
@ -161,15 +161,15 @@ async fn traverse(mut queue: Vec<NextcloudResponse>) {
|
|||
if !resource_type.collection.is_empty() {
|
||||
// Get the contents XML
|
||||
let folder_contents: String = get_folder_contents(
|
||||
&queue[current_index].href,
|
||||
&result.response[current_index].href,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
debug!("{:?}", folder_contents);
|
||||
// Parse the contents XML into Multistatus
|
||||
let mut result: Multistatus = from_str(&String::from(folder_contents)).unwrap();
|
||||
// Append the NextcloudResponse vector to queue
|
||||
queue.append(&mut result.response);
|
||||
let mut new_result: Multistatus = from_str(&String::from(folder_contents)).unwrap();
|
||||
// Append the NextcloudResponse vector to result.response
|
||||
result.response.append(&new_result.response);
|
||||
}
|
||||
}
|
||||
_ => current_index += 1,
|
||||
|
@ -228,6 +228,6 @@ async fn main() -> std::io::Result<()> {
|
|||
let mut result: Multistatus = from_str(&folder_contents).unwrap();
|
||||
println!("{:?}", result);
|
||||
|
||||
// traverse(result.response);
|
||||
traverse(&result);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue