mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-25 20:02:17 +00:00
feature update json data for safe read server res.
This commit is contained in:
@@ -4773,22 +4773,35 @@ void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
json jsonData = json::parse(body);
|
json jsonObj = json::parse(body);
|
||||||
auto errCode = jsonData["code"];
|
auto errCode = jsonObj["code"];
|
||||||
if (errCode != 200)
|
if (errCode != 200)
|
||||||
return;
|
return;
|
||||||
auto isFullUpgrade = jsonData["data"]["is_full_upgrade"];
|
|
||||||
auto isForceUpgrade = jsonData["data"]["is_force_upgrade"];
|
|
||||||
auto versionType = jsonData["data"]["stable"];
|
|
||||||
auto softPlatform = jsonData["data"]["platform_type"];
|
|
||||||
version_info.version_str = jsonData["data"]["version"];
|
|
||||||
|
|
||||||
auto fileSize = jsonData["data"]["full"]["file_size"];
|
auto dataObj = jsonObj.value("data", json::object());
|
||||||
auto fileMd5 = jsonData["data"]["full"]["file_md5"];
|
|
||||||
auto fileSha256 = jsonData["data"]["full"]["file_sha256"];
|
auto isFullUpgrade = dataObj.value("is_full_upgrade", true);
|
||||||
//windows x86_x64, mac arm/x86_x64 universal
|
auto isForceUpgrade = dataObj.value("is_force_upgrade", false);
|
||||||
version_info.url = jsonData["data"]["full"]["file_url"];
|
|
||||||
version_info.description = jsonData["data"]["full"]["file_describe"];
|
version_info.version_str = dataObj.value("version", "");
|
||||||
|
auto releaseType = dataObj.value("release_type", "");
|
||||||
|
auto platformType = dataObj.value("platform_type", "");
|
||||||
|
int fileSize = 0;
|
||||||
|
std::string fileMd5 = "";
|
||||||
|
std::string fileSha256 = "";
|
||||||
|
std::string reservedData = "";
|
||||||
|
std::string reservedData2 = "";
|
||||||
|
|
||||||
|
auto fullObj = dataObj.value("full", json::object());
|
||||||
|
fileSize = fullObj.value("file_size", 0);
|
||||||
|
fileMd5 = fullObj.value("file_md5", "");
|
||||||
|
fileSha256 = fullObj.value("file_sha256", "");
|
||||||
|
// windows x86_x64, mac arm/x86_x64 universal
|
||||||
|
version_info.url = fullObj.value("file_url", "");
|
||||||
|
version_info.description = fullObj.value("file_describe", "");
|
||||||
|
reservedData = fullObj.value("reserved_1", "");
|
||||||
|
reservedData2 = fullObj.value("reserved_2", "");
|
||||||
|
|
||||||
version_info.force_upgrade = isForceUpgrade;
|
version_info.force_upgrade = isForceUpgrade;
|
||||||
|
|
||||||
std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");
|
std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");
|
||||||
|
|||||||
@@ -727,7 +727,6 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
|
|||||||
wxString errorMsg = wxString::Format(_L("request to server update web resource fail with body:%s,error:%s,status:%d"), body, error, http_status);
|
wxString errorMsg = wxString::Format(_L("request to server update web resource fail with body:%s,error:%s,status:%d"), body, error, http_status);
|
||||||
evt->SetString(errorMsg);
|
evt->SetString(errorMsg);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_update_flutter_resource", http_status, error);
|
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_update_flutter_resource", http_status, error);
|
||||||
})
|
})
|
||||||
.timeout_connect(TIMEOUT_CONNECT)
|
.timeout_connect(TIMEOUT_CONNECT)
|
||||||
@@ -753,8 +752,8 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
|
|||||||
auto fileSha256 = dataObj.value("file_sha256", "");
|
auto fileSha256 = dataObj.value("file_sha256", "");
|
||||||
auto fileUrl = dataObj.value("file_url", "");
|
auto fileUrl = dataObj.value("file_url", "");
|
||||||
auto description = dataObj.value("file_describe", "");
|
auto description = dataObj.value("file_describe", "");
|
||||||
auto reserveData = dataObj.value("reserve_1", "");
|
auto reservedData = dataObj.value("reserved_1", "");
|
||||||
auto reserveData2 = dataObj.value("reserve_2", "");
|
auto reservedData2 = dataObj.value("reserved_2", "");
|
||||||
|
|
||||||
auto localProfilesjson = cache_path / "flutter_web/version.json";
|
auto localProfilesjson = cache_path / "flutter_web/version.json";
|
||||||
std::string json_path = data_dir() + "/web/flutter_web/version.json";
|
std::string json_path = data_dir() + "/web/flutter_web/version.json";
|
||||||
@@ -834,22 +833,24 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
|
|||||||
if (http_status != 200)
|
if (http_status != 200)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
json jsonData = json::parse(body);
|
json jsonObj = json::parse(body);
|
||||||
auto errCode = jsonData["code"];
|
auto errCode = jsonObj["code"];
|
||||||
if (errCode != 200)
|
if (errCode != 200)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto isForceUpgrade = jsonData["data"]["is_force_upgrade"];
|
auto dataObj = jsonObj.value("data", json::object());
|
||||||
auto minSupportPcVersion = jsonData["data"]["min_support_pc_version"];
|
|
||||||
auto maxSupportPcVersion = jsonData["data"]["max_support_pc_version"];
|
auto isForceUpgrade = dataObj.value("is_force_upgrade", false);
|
||||||
auto fileVersion = jsonData["data"]["file_version"];
|
auto minSupportPcVersion = dataObj.value("min_support_pc_version", "");
|
||||||
auto fileSize = jsonData["data"]["file_size"];
|
auto maxSupportPcVersion = dataObj.value("max_support_pc_version", "");
|
||||||
auto fileMd5 = jsonData["data"]["file_md5"];
|
auto fileVersion = dataObj.value("file_version", "");
|
||||||
auto fileSha256 = jsonData["data"]["file_sha256"];
|
auto fileSize = dataObj.value("file_size", 0);
|
||||||
auto fileUrl = jsonData["data"]["file_url"];
|
auto fileMd5 = dataObj.value("file_md5", "");
|
||||||
auto description = jsonData["data"]["file_describe"];
|
auto fileSha256 = dataObj.value("file_sha256", "");
|
||||||
auto reserverData = jsonData["data"]["reserver_1"];
|
auto fileUrl = dataObj.value("file_url", "");
|
||||||
auto reserverData2 = jsonData["data"]["reserver_2"];
|
auto description = dataObj.value("file_describe", "");
|
||||||
|
auto reservedData = dataObj.value("reserved_1", "");
|
||||||
|
auto reservedData2 = dataObj.value("reserved_2", "");
|
||||||
|
|
||||||
auto localProfilesjson = cache_path / "profiles/Snapmaker.json";
|
auto localProfilesjson = cache_path / "profiles/Snapmaker.json";
|
||||||
std::string json_path = data_dir() + "/system/Snapmaker.json";
|
std::string json_path = data_dir() + "/system/Snapmaker.json";
|
||||||
@@ -857,6 +858,16 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
|
|||||||
Semver currentPresetVersion = get_version_from_json(json_path);
|
Semver currentPresetVersion = get_version_from_json(json_path);
|
||||||
Semver remoteVersion(fileVersion);
|
Semver remoteVersion(fileVersion);
|
||||||
|
|
||||||
|
if (fileVersion.empty()) {
|
||||||
|
if (!isAuto_check) {
|
||||||
|
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_PRESET_UPDATE);
|
||||||
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << format("use check the web update.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::string localOtaPresetVersion = "";
|
std::string localOtaPresetVersion = "";
|
||||||
if (fs::exists(localProfilesjson)) {
|
if (fs::exists(localProfilesjson)) {
|
||||||
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
|
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
|
||||||
|
|||||||
Reference in New Issue
Block a user