Only use required memory size

This commit is contained in:
topjohnwu 2018-08-08 03:20:37 +08:00
parent 5109b9abfd
commit 3e3f38500d

View File

@ -147,7 +147,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
console.add("- Downloading zip"); console.add("- Downloading zip");
HttpURLConnection conn = WebService.mustRequest(Data.magiskLink, null); HttpURLConnection conn = WebService.mustRequest(Data.magiskLink, null);
buf = new BufferedInputStream(new ProgressStream(conn), conn.getContentLength()); buf = new BufferedInputStream(new ProgressStream(conn), conn.getContentLength());
buf.mark(Integer.MAX_VALUE); buf.mark(conn.getContentLength());
try (OutputStream out = new FileOutputStream(zip)) { try (OutputStream out = new FileOutputStream(zip)) {
ShellUtils.pump(buf, out); ShellUtils.pump(buf, out);
} }
@ -156,7 +156,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
} else { } else {
console.add("- Existing zip found"); console.add("- Existing zip found");
buf = new BufferedInputStream(new FileInputStream(zip), (int) zip.length()); buf = new BufferedInputStream(new FileInputStream(zip), (int) zip.length());
buf.mark(Integer.MAX_VALUE); buf.mark((int) zip.length());
} }
console.add("- Extracting files"); console.add("- Extracting files");