mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 20:03:47 +00:00
FIX: add protection of empty HMS folder
jira: [none] Change-Id: Ie963c58d525f8a40543104dcdb4f9ee3b188a03f (cherry picked from commit 126d5a14ee72163c5d48baf7acb4131c335f69cc)
This commit is contained in:
@@ -123,7 +123,20 @@ int HMSQuery::download_hms_related(const std::string& hms_type, const std::strin
|
|||||||
void HMSQuery::copy_from_data_dir_to_local()
|
void HMSQuery::copy_from_data_dir_to_local()
|
||||||
{
|
{
|
||||||
const fs::path& from_dir = fs::path(Slic3r::resources_dir()) / HMS_PATH;
|
const fs::path& from_dir = fs::path(Slic3r::resources_dir()) / HMS_PATH;
|
||||||
|
if (!fs::exists(from_dir))
|
||||||
|
{
|
||||||
|
assert(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const fs::path& to_dir = fs::path(Slic3r::data_dir()) / HMS_PATH;
|
const fs::path& to_dir = fs::path(Slic3r::data_dir()) / HMS_PATH;
|
||||||
|
if (!fs::exists(to_dir))
|
||||||
|
{
|
||||||
|
fs::create_directory(to_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
for (const auto& entry : fs::directory_iterator(from_dir))
|
for (const auto& entry : fs::directory_iterator(from_dir))
|
||||||
{
|
{
|
||||||
const fs::path& source_path = entry.path();
|
const fs::path& source_path = entry.path();
|
||||||
@@ -139,6 +152,11 @@ void HMSQuery::copy_from_data_dir_to_local()
|
|||||||
copy_file(source_path, dest_path);
|
copy_file(source_path, dest_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception&)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int HMSQuery::load_from_local(const std::string& hms_type, const std::string& dev_id_type, json* load_json, std::string& load_version)
|
int HMSQuery::load_from_local(const std::string& hms_type, const std::string& dev_id_type, json* load_json, std::string& load_version)
|
||||||
|
|||||||
Reference in New Issue
Block a user