diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index a8d3fa620d..4e17f94527 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -39,7 +39,7 @@ namespace Slic3r { static const std::string VERSION_CHECK_URL_STABLE = "https://api.github.com/repos/Snapmaker/OrcaSlicer/releases/latest"; static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/Snapmaker/OrcaSlicer/releases"; -static const std::string PROFILE_UPDATE_URL = "https://api.github.com/repos/Snapmaker/Orca_Presets/releases/latest"; +static const std::string PROFILE_UPDATE_URL = "https://public.resource.snapmaker.com/upgrade/packages/profile/preset_config.json"; static const std::string MODELS_STR = "models"; const std::string AppConfig::SECTION_FILAMENTS = "filaments"; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1b41d921de..fbc54ea07e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4747,6 +4747,9 @@ void GUI_App::check_new_version_sf(bool show_tips, bool by_user) } try { json jsonData = json::parse(body); + auto errCode = jsonData["code"]; + if (errCode != 200) + return; // auto isFullUpgrade = jsonData["is_full_upgrade"]; auto isForceUpgrade = jsonData["data"]["is_force_upgrade"]; version_info.version_str = jsonData["data"]["version"]; diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 0ec8c0bdc0..fe835cc1f0 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -227,6 +227,7 @@ struct PresetUpdater::priv void parse_version_string(const std::string& body) const; void sync_resources(std::string http_url, std::map &resources, bool check_patch = false, std::string current_version="", std::string changelog_file=""); void sync_config(); + bool download_file(const std::string& url, const std::string& target_path, int timeout_sec = 30, bool* cancel_flag = nullptr); void sync_tooltip(std::string http_url, std::string language); void sync_plugins(std::string http_url, std::string plugin_version); void sync_printer_config(std::string http_url); @@ -649,8 +650,65 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map() == "Not Found") { - // The current Orca version does not have any OTA updates, delete the cache file - if (fs::exists(cache_profile_path / "profiles")) - fs::remove_all(cache_profile_path / "profiles"); - if (fs::exists(cache_profile_update_file)) - fs::remove(cache_profile_update_file); - } - } catch (...) {} - } BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error); }) .timeout_connect(5) @@ -700,6 +746,27 @@ void PresetUpdater::priv::sync_config() if (http_status != 200) return; try { + + { + + json jsonData = json::parse(body); + auto errCode = jsonData["code"]; + if (errCode != 200) + return; + + auto isForceUpgrade = jsonData["data"]["is_force_upgrade"]; + auto fileVersion = jsonData["data"]["file_version"]; + auto fileSize = jsonData["data"]["file_size"]; + auto fileMd5 = jsonData["data"]["file_md5"]; + auto fileSha256 = jsonData["data"]["file_sha256"]; + auto fileUrl = jsonData["data"]["file_url"]; + auto description = jsonData["data"]["file_describe"]; + + std::string fileName = cache_profile_path.string() + "/profiles.zip"; + download_file(fileUrl, fileName); + } + + json j = json::parse(body); struct update