mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
FIX: update: add more logic to protect the file access
previous json lacks information github: https://github.com/bambulab/BambuStudio/issues/4050 Change-Id: Ieca2a440f58f77f91caeac00576a38c861b26a5b
This commit is contained in:
parent
012df4d262
commit
50e8e90dc8
1 changed files with 10 additions and 4 deletions
|
@ -815,19 +815,24 @@ bool PresetUpdater::priv::get_cached_plugins_version(std::string& cached_version
|
||||||
live555_library = cache_folder.string() + "/liblive555.so";
|
live555_library = cache_folder.string() + "/liblive555.so";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string changelog_file = cache_folder.string() + "/network_plugins.json";
|
||||||
if (boost::filesystem::exists(network_library)
|
if (boost::filesystem::exists(network_library)
|
||||||
&& boost::filesystem::exists(player_library)
|
&& boost::filesystem::exists(player_library)
|
||||||
&& boost::filesystem::exists(live555_library))
|
&& boost::filesystem::exists(live555_library)
|
||||||
|
&& boost::filesystem::exists(changelog_file))
|
||||||
{
|
{
|
||||||
std::string changelog_file = cache_folder.string() + "/network_plugins.json";
|
|
||||||
has_plugins = true;
|
has_plugins = true;
|
||||||
try {
|
try {
|
||||||
boost::nowide::ifstream ifs(changelog_file);
|
boost::nowide::ifstream ifs(changelog_file);
|
||||||
json j;
|
json j;
|
||||||
ifs >> j;
|
ifs >> j;
|
||||||
|
|
||||||
cached_version = j["version"];
|
if (j.contains("version"))
|
||||||
force = j["force"];
|
cached_version = j["version"];
|
||||||
|
if (j.contains("force"))
|
||||||
|
force = j["force"];
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": cached_version = "<<cached_version<<", force = " << force;
|
||||||
}
|
}
|
||||||
catch(nlohmann::detail::parse_error &err) {
|
catch(nlohmann::detail::parse_error &err) {
|
||||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<changelog_file<<" got a nlohmann::detail::parse_error, reason = " << err.what();
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<changelog_file<<" got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||||
|
@ -871,6 +876,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("cached plugins version %1% not newer than current %2%")%cached_version%curr_version;
|
BOOST_LOG_TRIVIAL(info) << boost::format("cached plugins version %1% not newer than current %2%")%cached_version%curr_version;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("cached plugins version %1% newer than current %2%")%cached_version%curr_version;
|
||||||
plugin_version = cached_version;
|
plugin_version = cached_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue