Skip to content

Commit

Permalink
fix(services/webdav): Add possibility to answer without response if f…
Browse files Browse the repository at this point in the history
…ile isn't exist (#4170)

Add possibility to answer without response if file isn't exist
  • Loading branch information
AJIOB authored Feb 7, 2024
1 parent a64e9a5 commit e628198
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/src/services/webdav/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use serde::Deserialize;

use super::error::parse_error;
use super::lister::Multistatus;
use super::lister::MultistatusOptional;
use super::lister::WebdavLister;
use super::writer::WebdavWriter;
use crate::raw::*;
Expand Down Expand Up @@ -303,10 +304,20 @@ impl Accessor for WebdavBackend {
}

let bs = resp.into_body().bytes().await?;
let result: Multistatus =
let result: MultistatusOptional =
quick_xml::de::from_reader(bs.reader()).map_err(new_xml_deserialize_error)?;
let item = result
.response

let response = match result.response {
Some(v) => v,
None => {
return Err(Error::new(
ErrorKind::NotFound,
"Failed getting item stat: response field was not found",
))
}
};

let item = response
.first()
.ok_or_else(|| {
Error::new(
Expand Down
5 changes: 5 additions & 0 deletions core/src/services/webdav/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ pub struct Multistatus {
pub response: Vec<ListOpResponse>,
}

#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct MultistatusOptional {
pub response: Option<Vec<ListOpResponse>>,
}

#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct ListOpResponse {
pub href: String,
Expand Down

0 comments on commit e628198

Please sign in to comment.