diff --git a/LaunchServer/source/response/ResponseThread.java b/LaunchServer/source/response/ResponseThread.java index 3751729..7cb7d59 100644 --- a/LaunchServer/source/response/ResponseThread.java +++ b/LaunchServer/source/response/ResponseThread.java @@ -52,8 +52,8 @@ // Process connection boolean cancelled = false; Throwable savedError = null; - try (HInput input = new HInput(socket.getInputStream()); - HOutput output = new HOutput(socket.getOutputStream())) + try (HInput input = new HInput(IOHelper.newBufferedInputStream(socket.getInputStream())); + HOutput output = new HOutput(IOHelper.newBufferedOutStream(socket.getOutputStream()))) { Type type = readHandshake(input, output); if (type == null) diff --git a/Launcher/source/helper/IOHelper.java b/Launcher/source/helper/IOHelper.java index 746d2ba..2b80011 100644 --- a/Launcher/source/helper/IOHelper.java +++ b/Launcher/source/helper/IOHelper.java @@ -745,6 +745,18 @@ Files.write(file, bytes, WRITE_OPTIONS); } + @LauncherAPI + public static OutputStream newBufferedOutStream(OutputStream out) + { + return new BufferedOutputStream(out); + } + + @LauncherAPI + public static InputStream newBufferedInputStream(InputStream in) + { + return new BufferedInputStream(in); + } + private static final class DeleteDirVisitor extends SimpleFileVisitor { private final Path dir; diff --git a/Launcher/source/request/Request.java b/Launcher/source/request/Request.java index 8fa726c..a1f9dc1 100644 --- a/Launcher/source/request/Request.java +++ b/Launcher/source/request/Request.java @@ -57,8 +57,8 @@ try (Socket socket = IOHelper.newSocket()) { socket.connect(IOHelper.resolve(config.address)); - try (HInput input = new HInput(socket.getInputStream()); - HOutput output = new HOutput(socket.getOutputStream())) + try (HInput input = new HInput(IOHelper.newBufferedInputStream(socket.getInputStream())); + HOutput output = new HOutput(IOHelper.newBufferedOutStream(socket.getOutputStream()))) { writeHandshake(input, output); return requestDo(input, output); diff --git a/Launcher/source/request/update/UpdateRequest.java b/Launcher/source/request/update/UpdateRequest.java index c7375da..f958e86 100644 --- a/Launcher/source/request/update/UpdateRequest.java +++ b/Launcher/source/request/update/UpdateRequest.java @@ -228,7 +228,7 @@ // Start file update MessageDigest digest = this.digest ? SecurityHelper.newDigest(DigestAlgorithm.MD5) : null; - try (OutputStream fileOutput = IOHelper.newOutput(file)) + try (OutputStream fileOutput = IOHelper.newBufferedOutStream(IOHelper.newOutput(file))) { long downloaded = 0L; @@ -255,6 +255,7 @@ totalDownloaded += length; updateState(filePath, downloaded, hFile.size); } + fileOutput.flush(); } // Verify digest