This is an automated email from the ASF dual-hosted git repository.

suyanhanx pushed a commit to branch empty-file-test
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/empty-file-test by this push:
     new 25b8a8aa3 path check when append enabled only
25b8a8aa3 is described below

commit 25b8a8aa3dd26a11b60d4117cd4add61278a8478
Author: suyanhanx <[email protected]>
AuthorDate: Mon Sep 18 12:54:00 2023 +0800

    path check when append enabled only
    
    Signed-off-by: suyanhanx <[email protected]>
---
 core/src/services/fs/backend.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/core/src/services/fs/backend.rs b/core/src/services/fs/backend.rs
index e1293f8b9..a225958d2 100644
--- a/core/src/services/fs/backend.rs
+++ b/core/src/services/fs/backend.rs
@@ -374,9 +374,10 @@ impl Accessor for FsBackend {
                 Self::ensure_write_abs_path(atomic_write_dir, 
&tmp_file_of(path)).await?;
 
             // If the target file exists, we should append to the end of it 
directly.
-            if tokio::fs::try_exists(&target_path)
-                .await
-                .map_err(parse_io_error)?
+            if op.append()
+                && tokio::fs::try_exists(&target_path)
+                    .await
+                    .map_err(parse_io_error)?
             {
                 (target_path, None)
             } else {
@@ -574,9 +575,10 @@ impl Accessor for FsBackend {
                 Self::blocking_ensure_write_abs_path(atomic_write_dir, 
&tmp_file_of(path))?;
 
             // If the target file exists, we should append to the end of it 
directly.
-            if Path::new(&target_path)
-                .try_exists()
-                .map_err(parse_io_error)?
+            if op.append()
+                && Path::new(&target_path)
+                    .try_exists()
+                    .map_err(parse_io_error)?
             {
                 (target_path, None)
             } else {

Reply via email to