FIX: add protection of empty HMS folder
jira: [none] Change-Id: Ie963c58d525f8a40543104dcdb4f9ee3b188a03f
This commit is contained in:
parent
d4354aa90e
commit
126d5a14ee
|
@ -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();
|
||||||
|
@ -140,6 +153,11 @@ void HMSQuery::copy_from_data_dir_to_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue