adoroszlai commented on code in PR #10117:
URL: https://github.com/apache/ozone/pull/10117#discussion_r3135746662


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/Archiver.java:
##########
@@ -79,12 +80,29 @@ public static byte[] readEntry(InputStream input, final 
long size)
     return output.toByteArray();
   }
 
+  private static TarArchiveEntry createBasicTarArchiveEntry(File file, String 
entryName)
+      throws IOException {
+    TarArchiveEntry entry = new TarArchiveEntry(entryName);
+    entry.setMode(TarArchiveEntry.DEFAULT_FILE_MODE);

Review Comment:
   I don't think `setMode` should be called.  `TarArchiveEntry(String)` sets 
mode depending on whether `name` ends with `/`.  It also sets `linkFlag`, which 
cannot be updated later.  I think we should rely on this behavior by ensuring 
name ends with `/` for directories.
   
   
https://github.com/apache/commons-compress/blob/commons-compress-1.28.0/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java#L616-L619



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/Archiver.java:
##########
@@ -79,12 +80,29 @@ public static byte[] readEntry(InputStream input, final 
long size)
     return output.toByteArray();
   }
 
+  private static TarArchiveEntry createBasicTarArchiveEntry(File file, String 
entryName)
+      throws IOException {
+    TarArchiveEntry entry = new TarArchiveEntry(entryName);
+    entry.setMode(TarArchiveEntry.DEFAULT_FILE_MODE);
+    try {
+      BasicFileAttributes attrs = Files.readAttributes(
+          file.toPath(), BasicFileAttributes.class);
+      entry.setLastModifiedTime(attrs.lastModifiedTime());
+      entry.setLastAccessTime(attrs.lastAccessTime());
+      entry.setCreationTime(attrs.creationTime());
+    } catch (IOException e) {
+      entry.setModTime(file.lastModified()); // fallback
+    }
+    entry.setSize(file.length());

Review Comment:
   May be better to skip `setSize` for directories.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to