[wip] Commit before string refactor

This commit is contained in:
Adam Cooper 2022-01-24 08:58:15 -05:00
parent e034933fc0
commit 767d77ffcc
2 changed files with 24 additions and 18 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
/target
.env
Cargo.lock
example*.xml
scratchpad/

View file

@ -8,8 +8,6 @@ use std::io::{self, BufReader, Write};
use std::collections::HashMap;
#[allow(unused)]
use yaserde_derive::{YaDeserialize, YaSerialize};
#[allow(unused)]
use array_tool::vec::Shift;
#[allow(unused)]
fn publicise() {}
@ -121,7 +119,8 @@ async fn get_folder_contents(url_tail: &str) -> Result<String, Box<dyn std::erro
Ok(response_text)
}
fn traverse(queue: Vec<NextcloudResponse>) {
#[tokio::main]
async fn traverse(queue: Vec<NextcloudResponse>) {
debug!("Entering: traverse()");
// Initialize the indexed "pointer"
let mut current_index: usize = 0;
@ -131,20 +130,11 @@ fn traverse(queue: Vec<NextcloudResponse>) {
match &queue[0].propstat[0].prop {
Some(prop) => {
match &prop.get_etag {
Some(etag) => {
visited_items.insert(etag, true);
()
},
_ => {
current_index += 1;
()
}
Some(etag) => { visited_items.insert(etag, true); () },
_ => current_index += 1
}
},
_ => {
current_index +=1;
()
}
_ => current_index += 1
}
// Depth first traversal
while !queue.is_empty() {
@ -155,10 +145,25 @@ fn traverse(queue: Vec<NextcloudResponse>) {
// If queue[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,
// or find another way to handle these structures.
match &prop.resource_type {
Some(resource_type) => {
if !resource_type.collection.is_empty() {
// Get the contents XML
/* TODO(amcooper): Fix argument
let folder_contents: String =
get_folder_contents(&queue[current_index].href.unwrap())
.await
.unwrap();
debug!("{:?}", folder_contents);
*/
// Parse the contents XML into Multistatus
// Append the NextcloudResponse vector to queue
}
},
_ => current_index += 1
}
}
// else
// if item is not public, publicise it.
@ -204,7 +209,8 @@ async fn main() -> std::io::Result<()> {
println!("Publicise it!");
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/2019_test_public")
get_folder_contents("/nextcloud/remote.php/dav/files/adam/test_public")
.await
.unwrap();
debug!("{:?}", folder_contents);