diff --git a/src/org/dclermonte/siba/model/SibaManager.java b/src/org/dclermonte/siba/model/SibaManager.java index 0f4736f..9144533 100644 --- a/src/org/dclermonte/siba/model/SibaManager.java +++ b/src/org/dclermonte/siba/model/SibaManager.java @@ -25,9 +25,12 @@ import org.apache.commons.compress.utils.IOUtils; public class SibaManager { + public static int pathLength; public static File backup(final File toto, final String target) throws ArchiveException, IOException { + pathLength = toto.getParentFile().getAbsolutePath().length(); + /* String outputFileNameWithoutExtension = toto.getName()+"-"+ LocalDateTime.now(); */ LocalDateTime date = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'_'H'H_'m"); @@ -53,6 +56,7 @@ public class SibaManager } */ gzCompress.write(fileTar); gzCompress.close(); + output.delete(); md5(output1, target + "/" + outputFileNameWithoutExtension + ".md5"); return output1; } @@ -61,13 +65,18 @@ public class SibaManager { for (File file : directory.listFiles()) { + if (file.isDirectory()) { directoryToSave(file, outputStream); } else { - outputStream.putArchiveEntry(new TarArchiveEntry(file)); + TarArchiveEntry tae = new TarArchiveEntry(file); + String pathPartiel = file.getPath().substring(pathLength); + tae.setName(pathPartiel); + /* outputStream.putArchiveEntry(new TarArchiveEntry(file)); */ + outputStream.putArchiveEntry(tae); IOUtils.copy(new FileInputStream(file), outputStream); outputStream.closeArchiveEntry(); }