From 0871b110671faff48e8a4e681e817070b8a56915 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 17 Apr 2020 17:45:48 +0300 Subject: [PATCH] [FIX] DirBridge.move --- .../src/main/java/pro/gravit/launcher/client/DirBridge.java | 3 ++- .../src/main/java/pro/gravit/utils/helper/IOHelper.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java b/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java index dc6fb4b5..8cd5b337 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/DirBridge.java @@ -52,9 +52,10 @@ public static void move(Path newDir) throws IOException { LogHelper.dev(LogHelper.toString(new Throwable("Check stack of call DirBridge with null path..."))); return; } + Path oldUpdates = dirUpdates; dirUpdates = newDir; LogHelper.dev(newDir.toString()); - IOHelper.move(dirUpdates, newDir); + IOHelper.move(oldUpdates, dirUpdates); } public static Path getAppDataDir() throws IOException { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java index 8d7d9455..6005e538 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java @@ -584,14 +584,13 @@ private MoveFileVisitor(Path from, Path to) { } @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - IOHelper.copy(file, to.resolve(from.relativize(file))); - Files.delete(file); + Files.move(file, to.resolve(from.relativize(file)), COPY_OPTIONS); return FileVisitResult.CONTINUE; } @@ -602,6 +601,7 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (exc != null) throw exc; if (!this.from.equals(dir)) Files.delete(dir); return FileVisitResult.CONTINUE; }