[FIX] DirBridge.move

This commit is contained in:
Zaxar163 2020-04-17 17:45:48 +03:00
parent 8d4473d5a3
commit 0871b11067
2 changed files with 5 additions and 4 deletions

View file

@ -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 {

View file

@ -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;
}