Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 54df6a6

Browse files
committed
修复在线更新版本失败后可能导致无法启动的bug
1 parent 893d824 commit 54df6a6

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

front/src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ export default {
7373
this.restatModel = true
7474
})
7575
.catch(() => {
76-
this.hasUpdate = false
77-
this.restatModel = true
7876
this.$Message.error(this.$t('update.error'))
7977
})
8078
},

main/src/main/java/org/pdown/gui/http/controller/NativeController.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,12 @@ public FullHttpResponse openUrl(Channel channel, FullHttpRequest request) throws
161161
public FullHttpResponse doUpdate(Channel channel, FullHttpRequest request) throws Exception {
162162
Map<String, Object> map = getJSONParams(request);
163163
String url = (String) map.get("path");
164-
String path = PathUtil.ROOT_PATH + File.separator + "proxyee-down-main.jar.bak";
164+
String path = PathUtil.ROOT_PATH + File.separator + "proxyee-down-main.jar.tmp";
165165
try {
166-
AppUtil.download(url, PathUtil.ROOT_PATH + File.separator + "proxyee-down-main.jar.bak");
166+
AppUtil.download(url, path);
167+
File updateTmpJar = new File(path);
168+
File updateBakJar = new File(updateTmpJar.getParent() + File.separator + "proxyee-down-main.jar.bak");
169+
updateTmpJar.renameTo(updateBakJar);
167170
} catch (Exception e) {
168171
File file = new File(path);
169172
if (file.exists()) {
@@ -174,9 +177,15 @@ public FullHttpResponse doUpdate(Channel channel, FullHttpRequest request) throw
174177
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
175178
}
176179

180+
@RequestMapping("doReplace")
181+
public FullHttpResponse doReplace(Channel channel, FullHttpRequest request) throws Exception {
182+
System.out.println("proxyee-down-restart");
183+
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
184+
}
185+
177186
@RequestMapping("doRestart")
178187
public FullHttpResponse doRestart(Channel channel, FullHttpRequest request) throws Exception {
179-
System.out.println("proxyee-down-exit");
188+
System.out.println("proxyee-down-restart");
180189
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
181190
}
182191

main/src/main/java/org/pdown/gui/util/AppUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void download(String url, String path) throws IOException {
5555
URL u = new URL(url);
5656
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
5757
connection.setConnectTimeout(30000);
58-
connection.setReadTimeout(60000);
58+
connection.setReadTimeout(0);
5959
File file = new File(path);
6060
if (!file.exists() || file.isDirectory()) {
6161
FileUtil.createFileSmart(file.getPath());

main/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 3.01
1+
version: 3.02
22
spring:
33
profiles:
44
active: @environment@

0 commit comments

Comments
 (0)