Modified SibaBackup for empty directory
This commit is contained in:
parent
0662f108df
commit
a448d7e7bf
@ -58,7 +58,6 @@ public class SibaManager
|
||||
String outputFileNameWithoutExtension = fileToSave.getName() + "-" + textDate;
|
||||
|
||||
result = new File(target + "/" + outputFileNameWithoutExtension + ".tgz");
|
||||
|
||||
OutputStream gzipOutputStream = new GzipCompressorOutputStream(
|
||||
new BufferedOutputStream(new FileOutputStream(result)));
|
||||
TarArchiveOutputStream out = new TarArchiveOutputStream(gzipOutputStream);
|
||||
@ -137,7 +136,19 @@ public class SibaManager
|
||||
|
||||
if (file.isDirectory())
|
||||
{
|
||||
directoryToSave(file, outputStream, pathLength);
|
||||
if (file.listFiles().length == 0)
|
||||
{
|
||||
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file);
|
||||
String pathPartiel = file.getPath().substring(pathLength);
|
||||
tarArchiveEntry.setName(pathPartiel);
|
||||
outputStream.putArchiveEntry(tarArchiveEntry);
|
||||
outputStream.closeArchiveEntry();
|
||||
}
|
||||
else
|
||||
{
|
||||
directoryToSave(file, outputStream, pathLength);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,8 +46,8 @@ public class SibaManagerTest
|
||||
public void backupTest02() throws ArchiveException, IOException, SibaNullException
|
||||
{
|
||||
String md5LineSource = "qslfjqmlsfjmqlsjfqmlsjfsjf mqlsfjmljdf";
|
||||
File target = SibaManager.backup(new File("../data/simplestuff"), new File("../tmp/"));
|
||||
|
||||
File target = SibaManager.backup(new File("../data/simplestuff"), new File("/home/papou/tmp"));
|
||||
System.out.println(target.getName());
|
||||
// Load md5 file.
|
||||
String encoding = null;
|
||||
String md5LineTarget = FileUtils.readFileToString(target, encoding);
|
||||
|
Loading…
Reference in New Issue
Block a user