Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinLin666 committed Nov 18, 2023
1 parent f107dc0 commit 2fffc37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 0 additions & 2 deletions object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,6 @@ pub enum PutMode {
/// Perform an atomic write operation if the current version of the object matches the
/// provided [`UpdateVersion`], returning [`Error::Precondition`] otherwise
Update(UpdateVersion),
/// Only for Mounted path, drop the file before renaming so that the file will upload.
OverwriteUnsafe,
}

/// Uniquely identifies a version of an object to update
Expand Down
18 changes: 7 additions & 11 deletions object_store/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,13 @@ impl ObjectStore for LocalFileSystem {

let err = match file.write_all(&bytes) {
Ok(_) => match opts.mode {
PutMode::Overwrite => match std::fs::rename(&staging_path, &path) {
Ok(_) => None,
Err(source) => Some(Error::UnableToRenameFile { source }),
},
PutMode::Overwrite => {
std::mem::drop(file);
match std::fs::rename(&staging_path, &path) {
Ok(_) => None,
Err(source) => Some(Error::UnableToRenameFile { source }),
}
}
PutMode::Create => match std::fs::hard_link(&staging_path, &path) {
Ok(_) => {
let _ = std::fs::remove_file(&staging_path); // Attempt to cleanup
Expand All @@ -359,13 +362,6 @@ impl ObjectStore for LocalFileSystem {
},
},
PutMode::Update(_) => unreachable!(),
PutMode::OverwriteUnsafe => {
std::mem::drop(file);
match std::fs::rename(&staging_path, &path) {
Ok(_) => None,
Err(source) => Some(Error::UnableToRenameFile { source }),
}
}
},
Err(source) => Some(Error::UnableToCopyDataToFile { source }),
};
Expand Down
1 change: 0 additions & 1 deletion object_store/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ impl ObjectStore for InMemory {
PutMode::Overwrite => storage.overwrite(location, entry),
PutMode::Create => storage.create(location, entry)?,
PutMode::Update(v) => storage.update(location, v, entry)?,
PutMode::OverwriteUnsafe => storage.overwrite(location, entry),
}
storage.next_etag += 1;

Expand Down

0 comments on commit 2fffc37

Please sign in to comment.