improved semantic of tarDirectoryTree

This commit is contained in:
Didier Clermonté 2016-06-15 23:05:50 +02:00
parent 35794b0ff1
commit 3ef3009ea0
2 changed files with 14 additions and 2 deletions

View File

@ -92,7 +92,6 @@ public class SibaManager
} }
else else
{ {
int pathLength = fileToSave.getParentFile().getAbsolutePath().length();
LocalDateTime date = LocalDateTime.now(); LocalDateTime date = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH'h'mm'mn'ss's'"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH'h'mm'mn'ss's'");
String textDate = date.format(formatter); String textDate = date.format(formatter);
@ -101,7 +100,7 @@ public class SibaManager
gzipOutputStream = new GzipCompressorOutputStream( gzipOutputStream = new GzipCompressorOutputStream(
new BufferedOutputStream(new FileOutputStream(result))); new BufferedOutputStream(new FileOutputStream(result)));
out = new TarArchiveOutputStream(gzipOutputStream); out = new TarArchiveOutputStream(gzipOutputStream);
SibaUtils.tarDirectoryTree(fileToSave, out, pathLength); SibaUtils.tarDirectoryTree(fileToSave, out);
out.close(); out.close();
createMD5File(result, target + "/" + outputFileNameWithoutExtension + ".tgz.md5"); createMD5File(result, target + "/" + outputFileNameWithoutExtension + ".tgz.md5");
} }

View File

@ -151,6 +151,19 @@ public class SibaUtils
return result; return result;
} }
/**
*
* @param fileToSave
* @param outputStream
* @throws IOException
*/
public static void tarDirectoryTree(final File fileToSave, final TarArchiveOutputStream outputStream)
throws IOException
{
int pathLength = fileToSave.getParentFile().getAbsolutePath().length();
tarDirectoryTree(fileToSave, outputStream, pathLength);
}
/** /**
* *
* This method generates ArchiveEntry. * This method generates ArchiveEntry.