Skip to content

Commit

Permalink
path check when append enabled only
Browse files Browse the repository at this point in the history
Signed-off-by: suyanhanx <suyanhanx@gmail.com>
  • Loading branch information
suyanhanx committed Sep 18, 2023
1 parent 0558a6a commit 25b8a8a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/src/services/fs/backend.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 25b8a8a

Please sign in to comment.