diff options
author | Keuin <[email protected]> | 2023-01-13 02:49:57 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-01-13 02:49:57 +0800 |
commit | 5dc6e700cbcbc01833a02a193f660a286b934898 (patch) | |
tree | 72cf4cc3cfae2b3a7fb978bc0c465e329909db3e /src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java | |
parent | ff7d23b5b915f04c2b5f3614701cb56cfc605228 (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.java | 11 |
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()); |