alamb commented on code in PR #4922:
URL: https://github.com/apache/arrow-rs/pull/4922#discussion_r1361950307


##########
object_store/src/local.rs:
##########
@@ -996,15 +995,32 @@ fn convert_metadata(metadata: Metadata, location: Path) 
-> Result<ObjectMeta> {
     let size = 
usize::try_from(metadata.len()).context(FileSizeOverflowedUsizeSnafu {
         path: location.as_ref(),
     })?;
+    let inode = get_inode(&metadata);
+    let mtime = last_modified.timestamp_micros();
+
+    // Use an ETag scheme based on that used by many popular HTTP servers
+    // <https://httpd.apache.org/docs/2.2/mod/core.html#fileetag>
+    // 
<https://stackoverflow.com/questions/47512043/how-etags-are-generated-and-configured>
+    let etag = format!("{inode:x}-{mtime:x}-{size:x}");
 
     Ok(ObjectMeta {
         location,
         last_modified,
         size,
-        e_tag: None,
+        e_tag: Some(etag),
     })
 }
 
+#[cfg(unix)]
+fn get_inode(metadata: &Metadata) -> u64 {
+    std::os::unix::fs::MetadataExt::ino(metadata)
+}
+
+#[cfg(not(unix))]
+fn get_inode(metadata: &Metadata) -> u64 {
+    0

Review Comment:
   I see you have clarified the comment that inode is used to be more resistent 
to collisions -- sounds good to me



-- 
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