diff --git a/src/main/java/me/eigenraven/lwjgl3ify/relauncher/Downloader.java b/src/main/java/me/eigenraven/lwjgl3ify/relauncher/Downloader.java index b326ba0..8b5c035 100644 --- a/src/main/java/me/eigenraven/lwjgl3ify/relauncher/Downloader.java +++ b/src/main/java/me/eigenraven/lwjgl3ify/relauncher/Downloader.java @@ -348,9 +348,13 @@ public Path targetLocation() { public void download() throws IOException { final Path targetDir = targetLocation.getParent(); + final Path tempLocation = targetDir.resolve( + targetLocation.getFileName() + .toString() + ".tmp"); Files.createDirectories(targetDir); Files.deleteIfExists(targetLocation); + Files.deleteIfExists(tempLocation); byte[] data = null; Relauncher.logger.info("Downloading {} from {}", targetLocation, sourceUrl); @@ -372,7 +376,8 @@ public void download() throws IOException { } } Objects.requireNonNull(data); - Files.write(targetLocation, data); + Files.write(tempLocation, data); + Files.move(tempLocation, targetLocation); } @Override