upgrade tokio
continuous-integration/drone/push Build is passing Details

This commit is contained in:
LordMZTE 2021-06-18 21:52:35 +02:00
parent a5629ea741
commit 0d3a772432
3 changed files with 20 additions and 20 deletions

View File

@ -25,11 +25,12 @@ fuzzy-matcher = "0.3.7"
jm_client_core = { path = "../jm_client_core" }
log = "0.4.11"
opener = "0.4.1"
reqwest = { version = "0.10", features = ["stream"] }
reqwest = { version = "0.11", features = ["stream", "multipart"] }
serde_json = "1.0.60"
structopt = "0.3.21"
term-table = "1.3.0"
term_size = "0.3.2"
tokio = { version = "0.2.23", features = ["macros", "fs", "process"] }
tokio = { version = "1.7.0", features = ["macros", "fs", "process", "rt-multi-thread"] }
tokio-util = { version = "0.6.7", features = ["codec"] }
url = "2.2.0"

View File

@ -1,12 +1,11 @@
use crate::util;
use anyhow::{Result, bail};
use anyhow::{bail, Result};
use jm_client_core::{api::UpResp, JMClient};
use log::info;
use reqwest::{
multipart::{Form, Part},
Body,
};
use tokio::{fs::File, io::reader_stream};
use reqwest::multipart::{Form, Part};
use reqwest::Body;
use tokio::fs::File;
use tokio_util::codec::{BytesCodec, FramedRead};
pub async fn run(
client: &JMClient,
@ -27,10 +26,13 @@ pub async fn run(
.text("token", token)
.part(
"file",
Part::stream(Body::wrap_stream(reader_stream({
info!("Opening file {}", &path);
File::open(path).await?
})))
Part::stream(Body::wrap_stream(FramedRead::new(
{
info!("Opening file {}", &path);
File::open(path).await?
},
BytesCodec::new(),
)))
.file_name(name),
),
)
@ -43,15 +45,12 @@ pub async fn run(
let res = if let Ok(res) = serde_json::from_slice::<UpResp>(bytes) {
res
} else if let Ok(s) = std::str::from_utf8(bytes) {
bail!("Server responded with unexpected response: {}", s);
} else {
if let Ok(s) = std::str::from_utf8(bytes) {
bail!("Server responded with unexpected response: {}", s);
} else {
bail!("Server responded with invalid utf8 bytes: {:?}", bytes);
}
bail!("Server responded with invalid utf8 bytes: {:?}", bytes);
};
println!("Server responded with code {}", status);
if !open {

View File

@ -12,9 +12,9 @@ env_logger = "0.8.2"
lazy_static = "1.4.0"
log = "0.4.11"
once_cell = "1.5.2"
reqwest = "0.10.9"
reqwest = "0.11.3"
serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.60"
thiserror = "1.0.23"
tokio = { version = "0.2.23", features = ["macros", "fs"] }
tokio = { version = "1.7.0", features = ["macros", "fs", "rt-multi-thread"] }
url = "2.2.0"