-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webdav): add list and improve create (#1330)
* add initial * add list response * add webdav list_response parser * add more response * RFR: making PUT more generic * progress implementatin * add dir_stream * make fields public * finish backend * finish * rename to DirStream * add file header * fix lint * update comments * set_capabilities * address backend feedbacks * refine lock & clean up * fix logic * fix lint: dir_stream.rs * trying to fix * Update src/services/webdav/dir_stream.rs per comment from @ClSlaid Co-authored-by: ClSlaid <[email protected]> * dav_ext_methods PROPFIND; * PROPFIND * fix formatting * improve nginx config * Install nginx full Signed-off-by: Xuanwo <[email protected]> * Fix apt install Signed-off-by: Xuanwo <[email protected]> * import module Signed-off-by: Xuanwo <[email protected]> * fix lint * nginx * build relative path * trying to fix self.root * add default depth for propfind * feat: support auth for HttpBackend (#1359) support auth for HttpBackend * feat: Add batch delete support (#1357) * Save work Signed-off-by: Xuanwo <[email protected]> * Refactor batch operater Signed-off-by: Xuanwo <[email protected]> * Add docs Signed-off-by: Xuanwo <[email protected]> * Add behavior test Signed-off-by: Xuanwo <[email protected]> * Format code Signed-off-by: Xuanwo <[email protected]> * Fix test on fs Signed-off-by: Xuanwo <[email protected]> --------- Signed-off-by: Xuanwo <[email protected]> * docs: clarify about opendal user defined client (#1356) * docs: clarify opendal user defined client 1. no auto redirection 2. examples for disable it Signed-off-by: ClSlaid <[email protected]> * fix: make document test compilable Signed-off-by: ClSlaid <[email protected]> --------- Signed-off-by: ClSlaid <[email protected]> * fix(webhdfs): should prepend http:// scheme (#1354) * fix(webhdfs): should prepend http:// scheme Signed-off-by: ClSlaid <[email protected]> * refact: check scheme existence only on create Signed-off-by: ClSlaid <[email protected]> * fmt: make msrv-clippy happy Signed-off-by: ClSlaid <[email protected]> --------- Signed-off-by: ClSlaid <[email protected]> * ci: Pin time <= 0.3.17 until we decide to bump MSRV (#1361) * ci: Pin time <= 0.3.17 until we decide to bump MSRV Signed-off-by: Xuanwo <[email protected]> * Fix build Signed-off-by: Xuanwo <[email protected]> --------- Signed-off-by: Xuanwo <[email protected]> * ci: Only run service test on changing (#1363) Only run service test on changing Signed-off-by: Xuanwo <[email protected]> * add auth for propfind * fix list op * fix root path * add xml header * fix prop xml * remove TODO * skip current path while listing * handle 404 for dir * add MKCOL to fix mkdir * add MKCOL for dirs * end * create dir recursively * handle StatusCode::METHOD_NOT_ALLOWED * fix iteration * fix typo * fix dir creation * fix write --------- Signed-off-by: Xuanwo <[email protected]> Signed-off-by: ClSlaid <[email protected]> Co-authored-by: ClSlaid <[email protected]> Co-authored-by: Xuanwo <[email protected]> Co-authored-by: Young-Flash <[email protected]>
- Loading branch information
1 parent
3141029
commit 9896845
Showing
7 changed files
with
692 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2022 Datafuse Labs. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::raw::build_rel_path; | ||
use crate::Result; | ||
use crate::{raw::output, ObjectMetadata, ObjectMode}; | ||
use async_trait::async_trait; | ||
|
||
use super::list_response::Multistatus; | ||
|
||
pub struct DirStream { | ||
root: String, | ||
path: String, | ||
size: usize, | ||
multistates: Multistatus, | ||
} | ||
|
||
impl DirStream { | ||
pub fn new(root: &str, path: &str, multistates: Multistatus, limit: Option<usize>) -> Self { | ||
Self { | ||
root: root.into(), | ||
path: path.into(), | ||
size: limit.unwrap_or(1000), | ||
multistates, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl output::Page for DirStream { | ||
async fn next_page(&mut self) -> Result<Option<Vec<output::Entry>>> { | ||
let mut oes: Vec<output::Entry> = Vec::new(); | ||
for _ in 0..self.size { | ||
if let Some(de) = self.multistates.response.pop() { | ||
let path = de.href.clone(); | ||
let normalized_path = &if self.root != path { | ||
build_rel_path(&self.root, &path) | ||
} else { | ||
path | ||
}; | ||
|
||
if normalized_path.eq(&self.path) { | ||
// WebDav server may return the current path as an entry. | ||
continue; | ||
} | ||
|
||
let entry = if de.propstat.prop.resourcetype.value | ||
== Some(super::list_response::ResourceType::Collection) | ||
{ | ||
output::Entry::new(normalized_path, ObjectMetadata::new(ObjectMode::DIR)) | ||
} else { | ||
output::Entry::new(normalized_path, ObjectMetadata::new(ObjectMode::FILE)) | ||
}; | ||
oes.push(entry); | ||
} | ||
} | ||
|
||
Ok(if oes.is_empty() { None } else { Some(oes) }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9896845
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for opendal ready!
✅ Preview
https://opendal-qpsxmqyx3-databend.vercel.app
Built with commit 9896845.
This pull request is being automatically deployed with vercel-action