Skip to content

Commit

Permalink
fix append logic
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorgan committed Aug 24, 2024
1 parent 037301e commit a12ecd5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/services/hdfs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ impl Access for HdfsBackend {
}
};

let should_append = op.append() && target_exists;
let tmp_path = self.atomic_write_dir.as_ref().and_then(|atomic_write_dir| {
// If the target file exists, we should append to the end of it directly.
if op.append() && target_exists {
if should_append {
None
} else {
Some(build_rooted_abs_path(atomic_write_dir, &tmp_file_of(path)))
Expand All @@ -321,7 +322,7 @@ impl Access for HdfsBackend {

let mut open_options = self.client.open_file();
open_options.create(true);
if op.append() {
if should_append {
open_options.append(true);
} else {
open_options.write(true);
Expand Down Expand Up @@ -493,9 +494,10 @@ impl Access for HdfsBackend {
}
};

let should_append = op.append() && target_exists;
let tmp_path = self.atomic_write_dir.as_ref().and_then(|atomic_write_dir| {
// If the target file exists, we should append to the end of it directly.
if op.append() && target_exists {
if should_append {
None
} else {
Some(build_rooted_abs_path(atomic_write_dir, &tmp_file_of(path)))
Expand All @@ -514,7 +516,7 @@ impl Access for HdfsBackend {

let mut open_options = self.client.open_file();
open_options.create(true);
if op.append() {
if should_append {
open_options.append(true);
} else {
open_options.write(true);
Expand Down

0 comments on commit a12ecd5

Please sign in to comment.