FIX: save the original cloud HMS file
jira: [none] Change-Id: I1e0987203d06274e4018e4bad12d9d796f3a26a0
This commit is contained in:
parent
f3992d3e94
commit
ed9c29d7a5
|
@ -74,11 +74,13 @@ int HMSQuery::download_hms_related(const std::string& hms_type, const std::strin
|
||||||
|
|
||||||
|
|
||||||
bool to_save_local = false;
|
bool to_save_local = false;
|
||||||
|
json j;
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "hms: download url = " << url;
|
BOOST_LOG_TRIVIAL(info) << "hms: download url = " << url;
|
||||||
Slic3r::Http http = Slic3r::Http::get(url);
|
Slic3r::Http http = Slic3r::Http::get(url);
|
||||||
http.on_complete([this, receive_json, hms_type, &to_save_local, &local_version](std::string body, unsigned status) {
|
http.on_complete([this, receive_json, hms_type, &to_save_local, &j, & local_version](std::string body, unsigned status) {
|
||||||
try {
|
try {
|
||||||
json j = json::parse(body);
|
j = json::parse(body);
|
||||||
if (j.contains("result")) {
|
if (j.contains("result")) {
|
||||||
if (j["result"] == 0 && j.contains("data")) {
|
if (j["result"] == 0 && j.contains("data")) {
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ int HMSQuery::download_hms_related(const std::string& hms_type, const std::strin
|
||||||
}).perform_sync();
|
}).perform_sync();
|
||||||
|
|
||||||
if (to_save_local && !receive_json->empty()) {
|
if (to_save_local && !receive_json->empty()) {
|
||||||
save_to_local(lang, hms_type, dev_id_type, *receive_json);
|
save_to_local(lang, hms_type, dev_id_type, j);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -192,41 +194,22 @@ int HMSQuery::load_from_local(const std::string& hms_type, const std::string& de
|
||||||
try {
|
try {
|
||||||
if (json_file.is_open())
|
if (json_file.is_open())
|
||||||
{
|
{
|
||||||
if (package_dev_id_types.count(dev_id_type) != 0) /*temp for 094, the local file structure is different from saved cloud file*/
|
const json &j = json::parse(json_file);
|
||||||
{
|
if (hms_type.compare(QUERY_HMS_INFO) == 0) {
|
||||||
if (hms_type == QUERY_HMS_INFO)
|
(*load_json) = j["data"];
|
||||||
{
|
} else if (hms_type.compare(QUERY_HMS_ACTION) == 0) {
|
||||||
const json& j = json::parse(json_file);
|
(*load_json)["data"] = j["data"];
|
||||||
if (j.contains("data"))
|
}
|
||||||
{
|
|
||||||
*load_json = j["data"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
json_file >> (*load_json);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((*load_json).contains("ver"))
|
if (j.contains("version")) {
|
||||||
{
|
load_version = JsonValParser::get_longlong_val(j["version"]);
|
||||||
load_version = JsonValParser::get_longlong_val((*load_json)["ver"]);
|
}
|
||||||
}
|
else if (j.contains("ver")) {
|
||||||
else
|
load_version = JsonValParser::get_longlong_val(j["ver"]);
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(warning) << "HMS: load_from_local, no version info";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_file >> (*load_json);
|
BOOST_LOG_TRIVIAL(warning) << "HMS: load_from_local, no version info";
|
||||||
if ((*load_json).contains("version"))
|
|
||||||
{
|
|
||||||
load_version = JsonValParser::get_longlong_val((*load_json)["version"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(warning) << "HMS: load_from_local, no version info";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -599,6 +582,7 @@ void HMSQuery::clear_hms_info()
|
||||||
std::unique_lock unique_lock(m_hms_mutex);
|
std::unique_lock unique_lock(m_hms_mutex);
|
||||||
m_hms_info_jsons.clear();
|
m_hms_info_jsons.clear();
|
||||||
m_hms_action_jsons.clear();
|
m_hms_action_jsons.clear();
|
||||||
|
m_cloud_hms_last_update_time.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMSQuery::init_hms_info(const std::string& dev_type_id)
|
void HMSQuery::init_hms_info(const std::string& dev_type_id)
|
||||||
|
|
Loading…
Reference in New Issue