mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Fix the network plugin OTA update flow
This commit is contained in:
@@ -782,9 +782,9 @@ void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string languag
|
||||
// return true means there are plugins files
|
||||
bool PresetUpdater::priv::get_cached_plugins_version(std::string& cached_version, bool &force)
|
||||
{
|
||||
std::string data_dir_str = data_dir();
|
||||
boost::filesystem::path data_dir_path(data_dir_str);
|
||||
auto cache_folder = data_dir_path / "ota";
|
||||
// The OTA plugin cache lives in its own ota/plugins subfolder; the update dialog
|
||||
// (Plater::priv::update_plugin_when_launch) reads the changelog from the same place.
|
||||
auto cache_folder = cache_path / "plugins";
|
||||
std::string network_library, player_library, live555_library;
|
||||
bool has_plugins = false;
|
||||
|
||||
@@ -838,6 +838,25 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
||||
}
|
||||
std::string curr_version = GUI::wxGetApp().use_legacy_network_plugin() ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : get_latest_network_version();
|
||||
std::string using_version = curr_version.substr(0, 9) + "00";
|
||||
auto cache_plugin_folder = cache_path / "plugins";
|
||||
|
||||
// Orca: drop leftovers from the old flat ota/ cache layout (pre ota/plugins) so the
|
||||
// stale files cannot linger forever after this layout migration.
|
||||
{
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
const char* legacy_names[] = {"bambu_networking.dll", "BambuSource.dll", "live555.dll", "network_plugins.json"};
|
||||
#elif defined(__WXMAC__)
|
||||
const char* legacy_names[] = {"libbambu_networking.dylib", "libBambuSource.dylib", "liblive555.dylib", "network_plugins.json"};
|
||||
#else
|
||||
const char* legacy_names[] = {"libbambu_networking.so", "libBambuSource.so", "liblive555.so", "network_plugins.json"};
|
||||
#endif
|
||||
for (const char* name : legacy_names) {
|
||||
boost::system::error_code ec;
|
||||
auto legacy_file = cache_path / name;
|
||||
if (boost::filesystem::exists(legacy_file, ec))
|
||||
boost::filesystem::remove(legacy_file, ec);
|
||||
}
|
||||
}
|
||||
|
||||
std::string cached_version;
|
||||
bool force_upgrade = false;
|
||||
@@ -868,64 +887,11 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
||||
}
|
||||
|
||||
if (need_delete_cache) {
|
||||
std::string data_dir_str = data_dir();
|
||||
boost::filesystem::path data_dir_path(data_dir_str);
|
||||
auto cache_folder = data_dir_path / "ota";
|
||||
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
auto network_library = cache_folder / "bambu_networking.dll";
|
||||
auto player_library = cache_folder / "BambuSource.dll";
|
||||
auto live555_library = cache_folder / "live555.dll";
|
||||
#elif defined(__WXMAC__)
|
||||
auto network_library = cache_folder / "libbambu_networking.dylib";
|
||||
auto player_library = cache_folder / "libBambuSource.dylib";
|
||||
auto live555_library = cache_folder / "liblive555.dylib";
|
||||
#else
|
||||
auto network_library = cache_folder / "libbambu_networking.so";
|
||||
auto player_library = cache_folder / "libBambuSource.so";
|
||||
auto live555_library = cache_folder / "liblive555.so";
|
||||
#endif
|
||||
auto changelog_file = cache_folder / "network_plugins.json";
|
||||
|
||||
if (boost::filesystem::exists(network_library))
|
||||
{
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the file "<<network_library.string();
|
||||
try {
|
||||
fs::remove(network_library);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins file " << network_library.string();
|
||||
}
|
||||
}
|
||||
if (boost::filesystem::exists(player_library))
|
||||
{
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the file "<<player_library.string();
|
||||
try {
|
||||
fs::remove(player_library);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins file " << player_library.string();
|
||||
}
|
||||
}
|
||||
if (boost::filesystem::exists(live555_library))
|
||||
{
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the file " << live555_library.string();
|
||||
try {
|
||||
fs::remove(live555_library);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins file " << live555_library.string();
|
||||
}
|
||||
}
|
||||
if (boost::filesystem::exists(changelog_file))
|
||||
{
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the file "<<changelog_file.string();
|
||||
try {
|
||||
fs::remove(changelog_file);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins file " << changelog_file.string();
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the plugins directory " << cache_plugin_folder.string();
|
||||
try {
|
||||
fs::remove_all(cache_plugin_folder);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins directory " << cache_plugin_folder.string();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -943,7 +909,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
||||
try {
|
||||
std::map<std::string, Resource> resources
|
||||
{
|
||||
{"slicer/plugins/cloud", { using_version, "", "", false, cache_path.string(), {"plugins"}}}
|
||||
{"slicer/plugins/cloud", { using_version, "", "", false, cache_plugin_folder.string()}}
|
||||
};
|
||||
sync_resources(http_url, resources, true, plugin_version, "network_plugins.json");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user