summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-01-13 02:49:57 +0800
committerKeuin <[email protected]>2023-01-13 02:49:57 +0800
commit5dc6e700cbcbc01833a02a193f660a286b934898 (patch)
tree72cf4cc3cfae2b3a7fb978bc0c465e329909db3e /src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java
parentff7d23b5b915f04c2b5f3614701cb56cfc605228 (diff)
Code cleanup.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java b/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java
index f17217a..c5d1115 100644
--- a/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java
+++ b/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Stream;
public class IncBackupInfoSerializer {
/**
@@ -77,10 +78,12 @@ public class IncBackupInfoSerializer {
throw new IllegalArgumentException("Given directory is invalid.");
}
List<Path> pathList = new ArrayList<>();
- Files.walk(directory.toPath(), 1).filter(p -> {
- File f = p.toFile();
- return f.isFile() && f.getName().endsWith(".kbi");
- }).forEach(pathList::add);
+ try (Stream<Path> walk = Files.walk(directory.toPath(), 1)) {
+ walk.filter(p -> {
+ File f = p.toFile();
+ return f.isFile() && f.getName().endsWith(".kbi");
+ }).forEach(pathList::add);
+ }
List<SavedIncrementalBackup> objectList = new ArrayList<>();
for (Path path : pathList) {
SavedIncrementalBackup info = IncBackupInfoSerializer.fromFile(path.toFile());