Skip to content

Commit 8e5cc8b

Browse files
committed
fix: abort update when no matching asset is found
Fixes #217 (followup). When the GitHub release assets do not contain a jar matching the running mode (-GUI.jar or -CLI.jar), the loop previously exited silently, then the code spawned the Update process pointing at a non-existent update.jar and called System.exit(0). The user saw RetroMCP just close with no feedback. Now the update aborts with a clear IOException, surfaced through the standard task error dialog.
1 parent c094346 commit 8e5cc8b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/java/org/mcphackers/mcp/tasks/TaskDownloadUpdate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,23 @@ protected Stage[] setStages() {
3636
boolean confirmed = mcp.updateDialogue(notes, latestVersion);
3737
if (confirmed) {
3838
log("Downloading update...");
39+
boolean downloaded = false;
3940
for (Object obj : releaseJson.getJSONArray("assets")) {
4041
if (obj instanceof JSONObject) {
4142
JSONObject assetObj = (JSONObject) obj;
4243
if (!assetObj.getString("name").endsWith(mcp.isGUI() ? "-GUI.jar" : "-CLI.jar")) {
4344
continue;
4445
}
4546
FileUtil.downloadFile(assetObj.getString("browser_download_url"), Paths.get(MCPPaths.UPDATE_JAR));
47+
downloaded = true;
4648
break;
4749
}
4850
}
51+
if (!downloaded) {
52+
IOException t = new IOException("No matching update asset found in release! Aborting");
53+
Util.throwExceptionInIDE(t);
54+
throw t;
55+
}
4956
Path jarPath = Paths.get(MCP.class
5057
.getProtectionDomain()
5158
.getCodeSource()

0 commit comments

Comments
 (0)