RobinLin666 commented on code in PR #5094:
URL: https://github.com/apache/arrow-rs/pull/5094#discussion_r1398585138


##########
object_store/src/local.rs:
##########
@@ -338,28 +338,39 @@ impl ObjectStore for LocalFileSystem {
         maybe_spawn_blocking(move || {
             let (mut file, suffix) = new_staged_upload(&path)?;
             let staging_path = staged_upload_path(&path, &suffix);
+            let mut e_tag = None;
 
             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::Create => match std::fs::hard_link(&staging_path, 
&path) {
-                        Ok(_) => {
-                            let _ = std::fs::remove_file(&staging_path); // 
Attempt to cleanup
-                            None
+                Ok(_) => {
+                    let metadata = file.metadata().map_err(|e| Error::Metadata 
{

Review Comment:
   Yes, it works with blobfuse. Because when it sends `stat` system call, 
blobfuse will look for local file cache firstly and it will success.



##########
object_store/src/local.rs:
##########
@@ -338,28 +338,39 @@ impl ObjectStore for LocalFileSystem {
         maybe_spawn_blocking(move || {
             let (mut file, suffix) = new_staged_upload(&path)?;
             let staging_path = staged_upload_path(&path, &suffix);
+            let mut e_tag = None;
 
             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::Create => match std::fs::hard_link(&staging_path, 
&path) {
-                        Ok(_) => {
-                            let _ = std::fs::remove_file(&staging_path); // 
Attempt to cleanup
-                            None
+                Ok(_) => {
+                    let metadata = file.metadata().map_err(|e| Error::Metadata 
{
+                        source: e.into(),
+                        path: path.to_string_lossy().to_string(),
+                    })?;
+                    e_tag = Some(get_etag(&metadata));
+                    match opts.mode {
+                        PutMode::Overwrite => {
+                            std::mem::drop(file);

Review Comment:
   Sure, thanks



##########
object_store/src/local.rs:
##########
@@ -338,28 +338,39 @@ impl ObjectStore for LocalFileSystem {
         maybe_spawn_blocking(move || {
             let (mut file, suffix) = new_staged_upload(&path)?;
             let staging_path = staged_upload_path(&path, &suffix);
+            let mut e_tag = None;
 
             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::Create => match std::fs::hard_link(&staging_path, 
&path) {
-                        Ok(_) => {
-                            let _ = std::fs::remove_file(&staging_path); // 
Attempt to cleanup
-                            None
+                Ok(_) => {
+                    let metadata = file.metadata().map_err(|e| Error::Metadata 
{

Review Comment:
   Hi @tustvold, you can see 
https://github.com/Azure/azure-storage-fuse/blob/master/blobfuse/utilities.cpp#L136
   <img width="1156" alt="image" 
src="https://github.com/apache/arrow-rs/assets/128118209/4dfbb452-6bd0-4d97-984c-38e7a2b94e85";>
   
   For `metadate` request, blobfuse will check local cache firstly and skip 
remote request. It's different with rename requests.



##########
object_store/src/local.rs:
##########
@@ -338,28 +338,39 @@ impl ObjectStore for LocalFileSystem {
         maybe_spawn_blocking(move || {
             let (mut file, suffix) = new_staged_upload(&path)?;
             let staging_path = staged_upload_path(&path, &suffix);
+            let mut e_tag = None;
 
             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::Create => match std::fs::hard_link(&staging_path, 
&path) {
-                        Ok(_) => {
-                            let _ = std::fs::remove_file(&staging_path); // 
Attempt to cleanup
-                            None
+                Ok(_) => {
+                    let metadata = file.metadata().map_err(|e| Error::Metadata 
{

Review Comment:
   Yes, I have tested it in local and it worked.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to