fix: fail to update

This commit is contained in:
huanghongxun
2020-04-17 14:17:10 +08:00
parent 32e9076198
commit 99f42db370
4 changed files with 5 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ public final class ForgeInstallTask extends Task<Version> {
private final Version version;
private Path installer;
private final ForgeRemoteVersion remote;
private Task<Void> dependent;
private FileDownloadTask dependent;
private Task<Version> dependency;
public ForgeInstallTask(DefaultDependencyManager dependencyManager, Version version, ForgeRemoteVersion remoteVersion) {
@@ -75,6 +75,7 @@ public final class ForgeInstallTask extends Task<Version> {
installer.toFile(), null)
.setCacheRepository(dependencyManager.getCacheRepository())
.setCaching(true);
dependent.addIntegrityCheckHandler(FileDownloadTask.ZIP_INTEGRITY_CHECK_HANDLER);
}
@Override

View File

@@ -26,8 +26,6 @@ import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.CompressingUtils;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.IOUtils;
import org.jackhuang.hmcl.util.io.NetworkUtils;
@@ -36,7 +34,6 @@ import org.tukaani.xz.XZInputStream;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
@@ -142,6 +139,7 @@ public class LibraryDownloadTask extends Task<Void> {
library.getDownload().getSha1() != null ? new IntegrityCheck("SHA-1", library.getDownload().getSha1()) : null)
.setCacheRepository(cacheRepository)
.setCaching(true);
task.addIntegrityCheckHandler(FileDownloadTask.ZIP_INTEGRITY_CHECK_HANDLER);
xz = false;
}
} catch (IOException e) {

View File

@@ -156,8 +156,6 @@ public class FileDownloadTask extends Task<Void> {
this.integrityCheck = integrityCheck;
this.retry = retry;
this.addIntegrityCheckHandler(ZIP_INTEGRITY_CHECK_HANDLER);
setName(file.getName());
setExecutor(Schedulers.io());
}

View File

@@ -178,9 +178,9 @@ public final class CompressingUtils {
// Since Java 8 throws ZipError stupidly
throw new ZipException(error.getMessage());
} catch (UnsupportedOperationException ex) {
throw new IOException("Not a zip file", ex);
throw new ZipException("Not a zip file");
} catch (FileSystemNotFoundException ex) {
throw new IOException("Java Environment is broken");
throw new ZipException("Java Environment is broken");
}
}