tustvold commented on code in PR #4922:
URL: https://github.com/apache/arrow-rs/pull/4922#discussion_r1355813655
##########
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:
The inode isn't strictly necessary, it is still a pretty strong ETag without
it, but on Unix systems we might as well make use of it.
A happy consequence of the way most operations create a new file and then
link it into place, is that the inode is actually a pretty good indicator
--
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]