From 0fd1e6ce5b02e88eb3dc8f5dea4de9459948f6f0 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu@web.de> Date: Mon, 11 May 2020 17:35:30 +0200 Subject: [PATCH] Clean up code slightly --- src/main.rs | 49 +++++++++++++++++-------------------------------- src/util.rs | 2 +- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8226a4e..edfb4de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ use std::time::Duration; mod util; use util::*; -const ILIAS_URL: &'static str = "https://ilias.studium.kit.edu/"; +const ILIAS_URL: &str = "https://ilias.studium.kit.edu/"; #[tokio::main] async fn main() { @@ -61,9 +61,7 @@ async fn main() { let mut path = ilias.opt.output.clone(); path.push(item.name()); let ilias = Arc::clone(&ilias); - task::spawn(async { - process_gracefully(ilias, path, item).await; - }); + task::spawn(process_gracefully(ilias, path, item)); } }, Err(e) => println!("{:?}", e) @@ -184,9 +182,7 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future { @@ -201,9 +197,7 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future { @@ -227,8 +221,8 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future, mut path: PathBuf, obj: Object) -> impl Future, mut path: PathBuf, obj: Object) -> impl Future, mut path: PathBuf, obj: Object) -> impl Future 0 { log!(0, "Ignoring older threads in {:?}..", path); @@ -376,12 +367,10 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future, mut path: PathBuf, obj: Object) -> impl Future, mut path: PathBuf, obj: Object) -> impl Future { @@ -441,7 +426,7 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future Result<()> { if let Err(e) = tokio::fs::create_dir(&path).await { if e.kind() != tokio::io::ErrorKind::AlreadyExists { - Err(e)?; + return Err(e.into()); } } Ok(())