diff --git a/core/src/services/webdav/backend.rs b/core/src/services/webdav/backend.rs index b35ee1fe2a4f..fd2edaf1545e 100644 --- a/core/src/services/webdav/backend.rs +++ b/core/src/services/webdav/backend.rs @@ -19,7 +19,6 @@ use std::collections::HashMap; use std::collections::VecDeque; use std::fmt::Debug; use std::fmt::Formatter; -use std::str::FromStr; use async_trait::async_trait; use bytes::Buf; @@ -180,15 +179,6 @@ impl Builder for WebdavBuilder { } }; - let uri = http::Uri::from_str(endpoint).map_err(|err| { - Error::new(ErrorKind::ConfigInvalid, "endpoint is invalid") - .set_source(err) - .with_context("service", Scheme::Webdav) - })?; - // Some webdav server may have base dir like `/remote.php/webdav/` - // returned in the `href`. - let base_dir = uri.path().trim_end_matches('/'); - let root = normalize_root(&self.config.root.take().unwrap_or_default()); debug!("backend use root {}", root); @@ -215,7 +205,6 @@ impl Builder for WebdavBuilder { debug!("backend build finished: {:?}", &self); Ok(WebdavBackend { endpoint: endpoint.to_string(), - base_dir: base_dir.to_string(), authorization: auth, root, client, @@ -227,7 +216,6 @@ impl Builder for WebdavBuilder { #[derive(Clone)] pub struct WebdavBackend { endpoint: String, - base_dir: String, root: String, client: HttpClient, @@ -391,7 +379,7 @@ impl Accessor for WebdavBackend { let result: Multistatus = quick_xml::de::from_reader(bs.reader()).map_err(new_xml_deserialize_error)?; - let l = WebdavLister::new(&self.base_dir, &self.root, path, result); + let l = WebdavLister::new(&self.root, path, result); Ok((RpList::default(), Some(oio::PageLister::new(l)))) } diff --git a/core/src/services/webdav/lister.rs b/core/src/services/webdav/lister.rs index 131084445064..d4d0241f3e77 100644 --- a/core/src/services/webdav/lister.rs +++ b/core/src/services/webdav/lister.rs @@ -21,7 +21,6 @@ use serde::Deserialize; use crate::raw::*; use crate::*; pub struct WebdavLister { - base_dir: String, root: String, path: String, multistates: Multistatus, @@ -29,9 +28,8 @@ pub struct WebdavLister { impl WebdavLister { /// TODO: sending request in `next_page` instead of in `new`. - pub fn new(base_dir: &str, root: &str, path: &str, multistates: Multistatus) -> Self { + pub fn new(root: &str, path: &str, multistates: Multistatus) -> Self { Self { - base_dir: base_dir.to_string(), root: root.into(), path: path.into(), multistates, @@ -46,10 +44,7 @@ impl oio::PageList for WebdavLister { let oes = self.multistates.response.clone(); for res in oes { - let path = res - .href - .strip_prefix(&self.base_dir) - .unwrap_or(res.href.as_str()); + let path = res.href.as_str(); // Ignore the root path itself. if self.root == path {