sadanand48 commented on code in PR #8477: URL: https://github.com/apache/ozone/pull/8477#discussion_r2132036281
########## hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/Archiver.java: ########## @@ -115,6 +119,29 @@ public static long includeFile(File file, String entryName, return bytes; } + public static void linkAndIncludeFile(File file, String entryName, + ArchiveOutputStream<TarArchiveEntry> archiveOutput, Path tmpDir) throws IOException { + File link = null; + try { + Files.createLink(tmpDir.resolve(file.getName()), file.toPath()); + link = tmpDir.resolve(file.getName()).toFile(); + TarArchiveEntry entry = archiveOutput.createArchiveEntry(link, entryName); + archiveOutput.putArchiveEntry(entry); + try (InputStream input = Files.newInputStream(link.toPath())) { + IOUtils.copyLarge(input, archiveOutput); + } + archiveOutput.closeArchiveEntry(); + } catch (IOException ioe) { + LOG.error("Couldn't create hardlink for file {} while including it in tarball.", + file.getAbsolutePath(), ioe); + } finally { + if (link != null) { + Files.deleteIfExists(link.toPath()); Review Comment: noted. -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org