mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 07:16:27 -04:00
Fix #424
This commit is contained in:
parent
a4a833bfdb
commit
c6b49545ff
@ -142,7 +142,7 @@ public final class LibraryDownloadTask extends Task {
|
|||||||
JarInputStream jar = new JarInputStream(new ByteArrayInputStream(data));
|
JarInputStream jar = new JarInputStream(new ByteArrayInputStream(data));
|
||||||
JarEntry entry = jar.getNextJarEntry();
|
JarEntry entry = jar.getNextJarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
byte[] eData = IOUtils.readFullyAsByteArray(jar);
|
byte[] eData = IOUtils.readFullyWithoutClosing(jar);
|
||||||
if (entry.getName().equals("checksums.sha1")) {
|
if (entry.getName().equals("checksums.sha1")) {
|
||||||
hashes = new String(eData, Charset.forName("UTF-8")).split("\n");
|
hashes = new String(eData, Charset.forName("UTF-8")).split("\n");
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,12 @@ public final class IOUtils {
|
|||||||
|
|
||||||
public static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
|
public static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
|
||||||
|
|
||||||
|
public static byte[] readFullyWithoutClosing(InputStream stream) throws IOException {
|
||||||
|
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||||
|
copyTo(stream, result);
|
||||||
|
return result.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static ByteArrayOutputStream readFully(InputStream stream) throws IOException {
|
public static ByteArrayOutputStream readFully(InputStream stream) throws IOException {
|
||||||
try (InputStream is = stream) {
|
try (InputStream is = stream) {
|
||||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user