Skip to content

Commit a6554bb

Browse files
committed
qwq
1 parent 475a19b commit a6554bb

3 files changed

Lines changed: 4 additions & 42 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,10 @@ public void onClink() {
494494
onUpgrade();
495495
} else if (updateState.get() == State.DOWNLOADING) {
496496
Controllers.dialog(new UpgradeDialog(latestVersion.get(), null));
497-
} else if (updateState.get() == State.SUCCESS) {
497+
} else if (updateState.get() == State.SUCCESS && !UPDATE_MODE.equals(EnumUpdateMode.SILENT)) {
498498
Task.runAsync(() -> {
499499
try {
500-
UpdateHandler.finishUpdate(downloadedHmcl, UPDATE_MODE == EnumUpdateMode.SILENT);
500+
UpdateHandler.finishUpdate(downloadedHmcl, false);
501501
} catch (IOException e) {
502502
LOG.warning("Failed to apply update", e);
503503
javafx.application.Platform.runLater(() -> {

HMCL/src/main/java/org/jackhuang/hmcl/upgrade/HMCLDownloadTask.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,10 @@
1919

2020
import org.jackhuang.hmcl.task.FileDownloadTask;
2121

22-
import java.nio.file.Files;
2322
import java.nio.file.Path;
2423

2524
public final class HMCLDownloadTask extends FileDownloadTask {
26-
27-
private final RemoteVersion.Type archiveFormat;
28-
2925
public HMCLDownloadTask(RemoteVersion version, Path target) {
3026
super(version.url(), target, version.integrityCheck());
31-
archiveFormat = version.type();
32-
}
33-
34-
@Override
35-
public void execute() throws Exception {
36-
super.execute();
37-
38-
try {
39-
Path target = getPath();
40-
switch (archiveFormat) {
41-
case JAR:
42-
break;
43-
default:
44-
throw new IllegalArgumentException("Unknown format: " + archiveFormat);
45-
}
46-
} catch (Throwable e) {
47-
try {
48-
Files.deleteIfExists(getPath());
49-
} catch (Throwable e2) {
50-
e.addSuppressed(e2);
51-
}
52-
throw e;
53-
}
5427
}
55-
5628
}

HMCL/src/main/java/org/jackhuang/hmcl/upgrade/RemoteVersion.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck;
2424
import org.jackhuang.hmcl.util.gson.JsonUtils;
2525
import org.jackhuang.hmcl.util.io.NetworkUtils;
26-
import org.jetbrains.annotations.NotNull;
2726

2827
import java.io.IOException;
2928
import java.util.Optional;
3029

31-
public record RemoteVersion(UpdateChannel channel, String version, String url, Type type, IntegrityCheck integrityCheck,
30+
public record RemoteVersion(UpdateChannel channel, String version, String url, IntegrityCheck integrityCheck,
3231
boolean preview, boolean force) {
3332

3433
public static RemoteVersion fetch(UpdateChannel channel, boolean preview, String url) throws IOException {
@@ -39,21 +38,12 @@ public static RemoteVersion fetch(UpdateChannel channel, boolean preview, String
3938
String jarHash = Optional.ofNullable(response.get("jarsha1")).map(JsonElement::getAsString).orElse(null);
4039
boolean force = Optional.ofNullable(response.get("force")).map(JsonElement::getAsBoolean).orElse(false);
4140
if (jarUrl != null && jarHash != null) {
42-
return new RemoteVersion(channel, version, jarUrl, Type.JAR, new IntegrityCheck("SHA-1", jarHash), preview, force);
41+
return new RemoteVersion(channel, version, jarUrl, new IntegrityCheck("SHA-1", jarHash), preview, force);
4342
} else {
4443
throw new IOException("No download url is available");
4544
}
4645
} catch (JsonParseException e) {
4746
throw new IOException("Malformed response", e);
4847
}
4948
}
50-
51-
@Override
52-
public @NotNull String toString() {
53-
return "[" + version + " from " + url + "]";
54-
}
55-
56-
public enum Type {
57-
JAR
58-
}
5949
}

0 commit comments

Comments
 (0)