You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/02/21 02:53:52 UTC
(opendal) branch main updated: fix(services/webdav): remove base_dir component (#4231)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 7303f78ffb fix(services/webdav): remove base_dir component (#4231)
7303f78ffb is described below
commit 7303f78ffb230cf76776c6848ce76f27cc38f116
Author: hoslo <ys...@gmail.com>
AuthorDate: Wed Feb 21 10:53:46 2024 +0800
fix(services/webdav): remove base_dir component (#4231)
---
core/src/services/webdav/backend.rs | 14 +-------------
core/src/services/webdav/lister.rs | 9 ++-------
2 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/core/src/services/webdav/backend.rs b/core/src/services/webdav/backend.rs
index b35ee1fe2a..fd2edaf154 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 1310844450..d4d0241f3e 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 {