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