More error reporting
This commit is contained in:
parent
293053134f
commit
7fc710d4f5
1 changed files with 11 additions and 7 deletions
|
@ -61,19 +61,21 @@ fn data_client(file: &str) -> Result<Easy2<Collector>, ()> {
|
|||
"https://cloud.seebruecke.org/public.php/webdav/data/{}",
|
||||
file
|
||||
);
|
||||
client.url(&url).map_err(|_| ())?;
|
||||
client.url(&url)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.username(include_str!("cloud_user.txt"))
|
||||
.map_err(|_| ())?;
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.http_auth(easy::Auth::new().auto(true))
|
||||
.map_err(|_| ())?;
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem"))
|
||||
.map_err(|_| ())?;
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
fn put_client(file: &str, payload: &[u8]) -> Result<Easy2<Collector>, ()> {
|
||||
let mut client = data_client(&file)?;
|
||||
client.put(true).map_err(|_| ())?;
|
||||
client.put(true)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.get_mut().1.extend_from_slice(payload);
|
||||
client.in_filesize(payload.len() as u64)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
|
@ -86,8 +88,10 @@ pub async fn pull_data(
|
|||
_state: State<'_, Mutex<AppState>>,
|
||||
) -> Result<String, ()> {
|
||||
let mut client = data_client("")?;
|
||||
client.custom_request("PROPFIND").map_err(|_| ())?;
|
||||
client.perform().map_err(|_| ())?;
|
||||
client.custom_request("PROPFIND")
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.perform()
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
let content = &client.get_ref().0;
|
||||
Ok(String::from_utf8_lossy(content).to_string())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue