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;
|
String outputFileNameWithoutExtension = fileToSave.getName() + "-" + textDate;
|
||||||
|
|
||||||
result = new File(target + "/" + outputFileNameWithoutExtension + ".tgz");
|
result = new File(target + "/" + outputFileNameWithoutExtension + ".tgz");
|
||||||
|
|
||||||
OutputStream gzipOutputStream = new GzipCompressorOutputStream(
|
OutputStream gzipOutputStream = new GzipCompressorOutputStream(
|
||||||
new BufferedOutputStream(new FileOutputStream(result)));
|
new BufferedOutputStream(new FileOutputStream(result)));
|
||||||
TarArchiveOutputStream out = new TarArchiveOutputStream(gzipOutputStream);
|
TarArchiveOutputStream out = new TarArchiveOutputStream(gzipOutputStream);
|
||||||
@ -136,9 +135,21 @@ public class SibaManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
|
{
|
||||||
|
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);
|
directoryToSave(file, outputStream, pathLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file);
|
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file);
|
||||||
|
@ -46,8 +46,8 @@ public class SibaManagerTest
|
|||||||
public void backupTest02() throws ArchiveException, IOException, SibaNullException
|
public void backupTest02() throws ArchiveException, IOException, SibaNullException
|
||||||
{
|
{
|
||||||
String md5LineSource = "qslfjqmlsfjmqlsjfqmlsjfsjf mqlsfjmljdf";
|
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.
|
// Load md5 file.
|
||||||
String encoding = null;
|
String encoding = null;
|
||||||
String md5LineTarget = FileUtils.readFileToString(target, encoding);
|
String md5LineTarget = FileUtils.readFileToString(target, encoding);
|
||||||
|
Loading…
Reference in New Issue
Block a user