Skip to content

Commit ed78429

Browse files
committed
stage2/ml9: move where file is moved and change temp file name
this should reduce issues where the file system may prevent the file move from happening. F.ex. cross file systems, or file being open due to the stream.
1 parent 66e4e40 commit ed78429

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

stage2/modlauncher9/src/main/java/gg/essential/loader/stage2/DedicatedJarLoader.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected static void downloadDedicatedJar(LoaderUI ui, Path modsDir, String gam
3636
ui.setDownloadSize(connection.getContentLength());
3737

3838
final Path target = modsDir.resolve(String.format("Essential %s (%s).jar", essentialVersion, gameVersion));
39-
final Path tempFile = Files.createTempFile("Dedicated Essential jar", "");
39+
final Path tempFile = Files.createFile(modsDir.resolve("Essential Jar Download.jar.tmp"));
4040

4141
try (
4242
final InputStream in = connection.getInputStream();
@@ -50,10 +50,12 @@ protected static void downloadDedicatedJar(LoaderUI ui, Path modsDir, String gam
5050
totalRead += read;
5151
ui.setDownloaded(totalRead);
5252
}
53-
54-
Files.move(tempFile, target, ATOMIC_MOVE);
5553
} finally {
56-
Files.deleteIfExists(tempFile);
54+
try {
55+
Files.move(tempFile, target, ATOMIC_MOVE);
56+
} finally {
57+
Files.deleteIfExists(tempFile);
58+
}
5759
}
5860
}
5961

0 commit comments

Comments
 (0)