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 2023/04/28 13:13:44 UTC
[incubator-opendal] 05/05: Fix
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch multipart-mixed
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit ae1756c7ab11820f8924230b41bbce8909a54cf4
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Fri Apr 28 21:12:32 2023 +0800
Fix
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/src/raw/http_util/multipart.rs | 6 ++++--
core/src/services/azblob/batch.rs | 12 ++++++------
core/src/services/azblob/core.rs | 6 ++++--
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/core/src/raw/http_util/multipart.rs b/core/src/raw/http_util/multipart.rs
index d9ec1013..1bff5df2 100644
--- a/core/src/raw/http_util/multipart.rs
+++ b/core/src/raw/http_util/multipart.rs
@@ -97,8 +97,6 @@ impl<T: Part> Multipart<T> {
// Insert content length with calculated size.
builder = builder.header(CONTENT_LENGTH, bs.len());
- log::debug!("current body:\n{}", String::from_utf8_lossy(&bs));
-
builder
.body(AsyncBody::Bytes(bs))
.map_err(new_request_build_error)
@@ -211,6 +209,10 @@ impl MixedPart {
}
/// Build a mixed part from a request.
+ ///
+ /// # Notes
+ ///
+ /// Mixed parts only takes the path from the request uri.
pub fn from_request(req: Request<AsyncBody>) -> Self {
let mut part_headers = HeaderMap::new();
part_headers.insert(CONTENT_TYPE, "application/http".parse().unwrap());
diff --git a/core/src/services/azblob/batch.rs b/core/src/services/azblob/batch.rs
index 41cbefab..c6004be0 100644
--- a/core/src/services/azblob/batch.rs
+++ b/core/src/services/azblob/batch.rs
@@ -29,12 +29,12 @@ pub(super) fn parse_batch_delete_response(
let mut reps = Vec::with_capacity(expect.len());
let mut resp_packs: Vec<&str> = body.trim().split(&format!("--{boundary}")).collect();
- // if resp_packs.len() != (expect.len() + 1) {
- // return Err(Error::new(
- // ErrorKind::Unexpected,
- // "invalid batch delete response",
- // ));
- // }
+ if resp_packs.len() != (expect.len() + 2) {
+ return Err(Error::new(
+ ErrorKind::Unexpected,
+ "invalid batch delete response",
+ ));
+ }
// drop the tail
resp_packs.pop();
for (resp_pack, name) in resp_packs[1..].iter().zip(expect.into_iter()) {
diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs
index 02e210bb..62665a0e 100644
--- a/core/src/services/azblob/core.rs
+++ b/core/src/services/azblob/core.rs
@@ -372,11 +372,13 @@ impl AzblobCore {
let mut multipart = Multipart::new();
- for path in paths.iter() {
+ for (idx, path) in paths.iter().enumerate() {
let mut req = self.azblob_delete_blob_request(path)?;
self.batch_sign(&mut req).await?;
- multipart = multipart.part(MixedPart::from_request(req));
+ multipart = multipart.part(
+ MixedPart::from_request(req).part_header("content-id".parse().unwrap(), idx.into()),
+ );
}
let req = Request::post(url);