From b171d46ce07a9ed9a426779fcff92dd1f56b3dd1 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 15 Feb 2021 18:13:44 +0800 Subject: Minor bugfix: incremental backup without `backups` directory created will fail. --- .../backup/method/ConfiguredIncrementalBackupMethod.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/operation/backup') diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java index 5fe532a..0c202e1 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethod.java @@ -75,6 +75,13 @@ public class ConfiguredIncrementalBackupMethod implements ConfiguredBackupMethod // legacy index file // ObjectCollectionSerializer.toFile(collection, new File(backupIndexFileSaveDirectory, backupIndexFileName)); + // create directory + final File indexDirectoryFile = new File(backupIndexFileSaveDirectory); + if (indexDirectoryFile.isFile()) + throw new IOException("There is a file which has the same name with index directory"); + if (!indexDirectoryFile.isDirectory() && !indexDirectoryFile.mkdirs()) + throw new IOException("Backup index save directory does not exist and we failed to create it"); + // newer saved info (with metadata) File indexFile = new File(backupIndexFileSaveDirectory, backupIndexFileName); BackupFileNameEncoder.BackupBasicInformation info = IncrementalBackupFileNameEncoder.INSTANCE.decode(backupIndexFileName); @@ -82,9 +89,9 @@ public class ConfiguredIncrementalBackupMethod implements ConfiguredBackupMethod collection, info.customName, info.time.atZone(ZoneId.systemDefault()), - copyResult.getBytesTotal(), - copyResult.getBytesCopied(), - copyResult.getFilesCopied(), + copyResult.getTotalBytes(), + copyResult.getCopiedBytes(), + copyResult.getCopiedFiles(), copyResult.getTotalFiles() )); -- cgit v1.2.3