From: Tuukka Lehtonen Date: Thu, 29 Mar 2018 11:41:33 +0000 (+0300) Subject: Fixed invalid comparison from AcornBackupProvider.RestoreCopyVisitor X-Git-Tag: v1.43.0~136^2~515 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f347cbef328d1ae417ae095c0e2d81a358bdd598;p=simantics%2Fplatform.git Fixed invalid comparison from AcornBackupProvider.RestoreCopyVisitor Also removed unnecessary Files.exists checks. refs #7847 Change-Id: I67d9d5a500824a275f4412ef2ecb7c2860f7f1c7 --- diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/backup/AcornBackupProvider.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/backup/AcornBackupProvider.java index f75d5864f..cb4b3cdee 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/backup/AcornBackupProvider.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/backup/AcornBackupProvider.java @@ -139,9 +139,7 @@ public class AcornBackupProvider implements IBackupProvider { return FileVisitResult.CONTINUE; } else if (dir.getParent().getFileName().toString().equals(IDENTIFIER)) { Path targetPath = toPath.resolve(dirName); - if (!Files.exists(targetPath)) { - Files.createDirectory(targetPath); - } + Files.createDirectories(targetPath); return FileVisitResult.CONTINUE; } else if (dirName.toString().length() == 1 && Character.isDigit(dirName.toString().charAt(0))) { int dirNameInt = Integer.parseInt(dirName.toString()); @@ -240,22 +238,19 @@ public class AcornBackupProvider implements IBackupProvider { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - Path dirName = dir.getFileName(); - if (dirName.equals(fromPath)) { + if (dir.equals(fromPath)) { Path targetPath = toPath.resolve(fromPath.relativize(dir)); - if (!Files.exists(targetPath)) { - Files.createDirectory(targetPath); - } + Files.createDirectories(targetPath); return FileVisitResult.CONTINUE; } else { - int dirNameInt = Integer.parseInt(dirName.toString()); - if (latestFolder < dirNameInt && dirNameInt <= newestFolder) { - Path targetPath = toPath.resolve(fromPath - .relativize(dir)); - if (!Files.exists(targetPath)) { - Files.createDirectory(targetPath); + try { + int dirNameInt = Integer.parseInt(dir.getFileName().toString()); + if (latestFolder < dirNameInt && dirNameInt <= newestFolder) { + Path targetPath = toPath.resolve(fromPath.relativize(dir)); + Files.createDirectories(targetPath); + return FileVisitResult.CONTINUE; } - return FileVisitResult.CONTINUE; + } catch (NumberFormatException e) { } return FileVisitResult.SKIP_SUBTREE; }