mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
improved version check - #2190
This commit is contained in:
@@ -1014,22 +1014,22 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
// request.url("/api");
|
||||
// EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||
|
||||
char data2[] = "{\"action\":\"customSupport\", \"param\":\"hello\"}";
|
||||
deserializeJson(doc, data2);
|
||||
request.url("/rest/action");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// char data2[] = "{\"action\":\"customSupport\", \"param\":\"hello\"}";
|
||||
// deserializeJson(doc, data2);
|
||||
// request.url("/rest/action");
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
char data3[] = "{\"action\":\"export\", \"param\":\"schedule\"}";
|
||||
deserializeJson(doc, data3);
|
||||
request.url("/rest/action");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// char data3[] = "{\"action\":\"export\", \"param\":\"schedule\"}";
|
||||
// deserializeJson(doc, data3);
|
||||
// request.url("/rest/action");
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
char data4[] = "{\"action\":\"export\", \"param\":\"allvalues\"}";
|
||||
deserializeJson(doc, data4);
|
||||
request.url("/rest/action");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// char data4[] = "{\"action\":\"export\", \"param\":\"allvalues\"}";
|
||||
// deserializeJson(doc, data4);
|
||||
// request.url("/rest/action");
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.0-dev.99\"}";
|
||||
char data5[] = "{\"action\":\"checkUpgrade\", \"param\":\"3.7.1-dev.99,3.7.0\"}";
|
||||
deserializeJson(doc, data5);
|
||||
request.url("/rest/action");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
@@ -203,18 +203,27 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
||||
}
|
||||
|
||||
// action = checkUpgrade
|
||||
bool WebStatusService::checkUpgrade(JsonObject root, std::string & latest_version) {
|
||||
root["emsesp_version"] = EMSESP_APP_VERSION;
|
||||
bool WebStatusService::checkUpgrade(JsonObject root, std::string & versions) {
|
||||
root["emsesp_version"] = EMSESP_APP_VERSION; // always send back current version
|
||||
|
||||
// versions holds the latest development version and stable version in one string, comma separated
|
||||
std::string latest_dev_version = versions.substr(0, versions.find(','));
|
||||
std::string latest_stable_version = versions.substr(versions.find(',') + 1);
|
||||
|
||||
if (!versions.empty()) {
|
||||
version::Semver200_version this_version(EMSESP_APP_VERSION); // current version
|
||||
bool using_dev_version = !this_version.prerelease().empty();
|
||||
version::Semver200_version latest_version(using_dev_version ? latest_dev_version : latest_stable_version); // latest version
|
||||
|
||||
root["upgradeable"] = (latest_version > this_version);
|
||||
|
||||
if (!latest_version.empty()) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
emsesp::EMSESP::logger().debug("Checking for upgrade: %s < %s", EMSESP_APP_VERSION, latest_version.c_str());
|
||||
emsesp::EMSESP::logger().debug("Checking for version upgrade. This version=%s, latest dev=%s, latest stable=%s. Upgradeable=%s",
|
||||
EMSESP_APP_VERSION,
|
||||
latest_dev_version.c_str(),
|
||||
latest_stable_version.c_str(),
|
||||
root["upgradeable"].as<bool>() ? "true" : "false");
|
||||
#endif
|
||||
|
||||
version::Semver200_version settings_version(EMSESP_APP_VERSION);
|
||||
version::Semver200_version this_version(latest_version);
|
||||
|
||||
root["upgradeable"] = (this_version > settings_version);
|
||||
}
|
||||
|
||||
return true; // always ok
|
||||
|
||||
Reference in New Issue
Block a user