|
11 | 11 | package com.searchcode.app.service.route; |
12 | 12 |
|
13 | 13 |
|
| 14 | +import com.google.gson.Gson; |
14 | 15 | import com.searchcode.app.App; |
15 | 16 | import com.searchcode.app.config.Values; |
16 | 17 | import com.searchcode.app.dao.Api; |
17 | 18 | import com.searchcode.app.dao.Data; |
18 | 19 | import com.searchcode.app.dao.Repo; |
19 | 20 | import com.searchcode.app.dto.Source; |
| 21 | +import com.searchcode.app.dto.Version; |
20 | 22 | import com.searchcode.app.model.RepoResult; |
21 | 23 | import com.searchcode.app.model.ValidatorResult; |
22 | 24 | import com.searchcode.app.service.*; |
@@ -480,19 +482,21 @@ public void reindexRepo(Request request, Response response) { |
480 | 482 | } |
481 | 483 |
|
482 | 484 | public String checkVersion() { |
483 | | - String version; |
| 485 | + Version version; |
484 | 486 | try { |
485 | | - version = IOUtils.toString(new URL("https://searchcode.com/product/version/")).replace("\"", Values.EMPTYSTRING); |
| 487 | + Gson gson = new Gson(); |
| 488 | + String downloaded = IOUtils.toString(new URL("https://searchcodeserver.com/version.json")); |
| 489 | + version = gson.fromJson(downloaded, Version.class); |
486 | 490 | } |
487 | | - catch(IOException ex) { |
| 491 | + catch(Exception ex) { |
488 | 492 | return "Unable to determine if running the latest version. Check https://searchcodeserver.com/pricing.html for the latest release."; |
489 | 493 | } |
490 | 494 |
|
491 | | - if (App.VERSION.equals(version)) { |
492 | | - return "Your searchcode server version " + version + " is the latest."; |
| 495 | + if (App.VERSION.equals(version.getVersion())) { |
| 496 | + return "Your searchcode server version " + App.VERSION + " is the latest."; |
493 | 497 | } |
494 | 498 | else { |
495 | | - return "Your searchcode server version " + App.VERSION + " instance is out of date. The latest version is " + version + "."; |
| 499 | + return "Your searchcode server version " + App.VERSION + " instance is out of date. The latest version is " + version.getVersion() + "."; |
496 | 500 | } |
497 | 501 | } |
498 | 502 |
|
|
0 commit comments