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/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new d789892b8 fix(core): Path in remove not normalized (#3671)
d789892b8 is described below

commit d789892b8d98d3699a0dd5e00be9e554ef3ce1b3
Author: Xuanwo <[email protected]>
AuthorDate: Mon Nov 27 22:09:36 2023 +0800

    fix(core): Path in remove not normalized (#3671)
    
    * fix(core): Path in remove not normalized
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix tests
    
    Signed-off-by: Xuanwo <[email protected]>
    
    ---------
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/types/operator/operator.rs |  2 ++
 core/tests/behavior/write.rs        | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/core/src/types/operator/operator.rs 
b/core/src/types/operator/operator.rs
index c0f08d515..635577976 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -911,6 +911,8 @@ impl Operator {
     /// # }
     /// ```
     pub async fn remove_via(&self, input: impl Stream<Item = String> + Unpin) 
-> Result<()> {
+        let input = input.map(|v| normalize_path(&v));
+
         if self.info().full_capability().batch {
             let mut input = input
                 .map(|v| (v, OpDelete::default().into()))
diff --git a/core/tests/behavior/write.rs b/core/tests/behavior/write.rs
index 88585947f..f76765945 100644
--- a/core/tests/behavior/write.rs
+++ b/core/tests/behavior/write.rs
@@ -1176,7 +1176,18 @@ pub async fn test_remove_one_file(op: Operator) -> 
Result<()> {
     let path = uuid::Uuid::new_v4().to_string();
     let (content, _) = gen_bytes(op.info().full_capability());
 
-    op.write(&path, content).await.expect("write must succeed");
+    op.write(&path, content.clone())
+        .await
+        .expect("write must succeed");
+
+    op.remove(vec![path.clone()]).await?;
+
+    // Stat it again to check.
+    assert!(!op.is_exist(&path).await?);
+
+    op.write(&format!("/{path}"), content)
+        .await
+        .expect("write must succeed");
 
     op.remove(vec![path.clone()]).await?;
 

Reply via email to