Update tokio to 1.0

This commit is contained in:
FliegendeWurst 2021-01-20 10:26:38 +01:00
parent c5b8cc7399
commit 711bfe8d17
3 changed files with 202 additions and 378 deletions

567
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.10.4", default-features = false, features = ["cookies", "gzip", "json", "rustls-tls", "stream"] }
tokio = { version = "0.2", features = ["full"] }
reqwest = { version = "0.11.0", default-features = false, features = ["cookies", "gzip", "json", "rustls-tls", "stream"] }
tokio = { version = "1.0.2", features = ["full"] }
tokio-util = { version = "0.6.1", features = ["io"] }
serde_json = "1.0.51"
scraper = "0.12.0"
url = "2.1.1"

View File

@ -11,8 +11,8 @@ use scraper::{ElementRef, Html, Selector};
use serde_json::json;
use structopt::StructOpt;
use tokio::fs;
use tokio::io::stream_reader;
use tokio::task::{self, JoinHandle};
use tokio_util::io::StreamReader;
use url::Url;
use std::{collections::HashSet, default::Default};
@ -138,7 +138,7 @@ fn process_gracefully(ilias: Arc<ILIAS>, path: PathBuf, obj: Object) -> impl Fut
break;
}
}
tokio::time::delay_for(Duration::from_millis(50)).await;
tokio::time::sleep(Duration::from_millis(50)).await;
}
let path_text = path.to_string_lossy().into_owned();
if let Err(e) = process(ilias, path, obj).await.context("failed to process URL") {
@ -256,7 +256,7 @@ fn process(ilias: Arc<ILIAS>, mut path: PathBuf, obj: Object) -> impl Future<Out
return Ok(());
}
let data = ilias.download(&url.url).await?;
let mut reader = stream_reader(data.bytes_stream().map_err(|x| {
let mut reader = StreamReader::new(data.bytes_stream().map_err(|x| {
io::Error::new(io::ErrorKind::Other, x)
}));
log!(0, "Writing {}", relative_path.to_string_lossy());
@ -360,7 +360,7 @@ fn process(ilias: Arc<ILIAS>, mut path: PathBuf, obj: Object) -> impl Future<Out
}
} else {
let resp = ilias.download(&url).await?;
let mut reader = stream_reader(resp.bytes_stream().map_err(|x| {
let mut reader = StreamReader::new(resp.bytes_stream().map_err(|x| {
io::Error::new(io::ErrorKind::Other, x)
}));
log!(0, "Writing {}", relative_path.to_string_lossy());