FIX: check path exist before create directories
Jira: XXXX Change-Id: Id79329a97e51944a339421aaf3594deb03211fb1
This commit is contained in:
parent
5ad579f929
commit
039ac0d69b
|
@ -493,11 +493,11 @@ void Preset::remove_files()
|
||||||
}
|
}
|
||||||
|
|
||||||
//BBS: add logic for only difference save
|
//BBS: add logic for only difference save
|
||||||
void Preset::save(DynamicPrintConfig* parent_config)
|
bool Preset::save(DynamicPrintConfig* parent_config)
|
||||||
{
|
{
|
||||||
//BBS: add project embedded preset logic
|
//BBS: add project embedded preset logic
|
||||||
if (this->is_project_embedded)
|
if (this->is_project_embedded)
|
||||||
return;
|
return false;
|
||||||
//BBS: change to json format
|
//BBS: change to json format
|
||||||
//this->config.save(this->file);
|
//this->config.save(this->file);
|
||||||
std::string from_str;
|
std::string from_str;
|
||||||
|
@ -510,7 +510,11 @@ void Preset::save(DynamicPrintConfig* parent_config)
|
||||||
else
|
else
|
||||||
from_str = std::string("Default");
|
from_str = std::string("Default");
|
||||||
|
|
||||||
boost::filesystem::create_directories(fs::path(this->file).parent_path());
|
boost::system::error_code ec;
|
||||||
|
if (!boost::filesystem::exists(fs::path(this->file).parent_path()) && !boost::filesystem::create_directories(fs::path(this->file).parent_path(), ec)) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << this->file << " " << ec.message();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//BBS: only save difference if it has parent
|
//BBS: only save difference if it has parent
|
||||||
if (parent_config) {
|
if (parent_config) {
|
||||||
|
@ -536,6 +540,7 @@ void Preset::save(DynamicPrintConfig* parent_config)
|
||||||
fs::path idx_file(this->file);
|
fs::path idx_file(this->file);
|
||||||
idx_file.replace_extension(".info");
|
idx_file.replace_extension(".info");
|
||||||
this->save_info(idx_file.string());
|
this->save_info(idx_file.string());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preset::reload(Preset const &parent)
|
void Preset::reload(Preset const &parent)
|
||||||
|
@ -1478,7 +1483,10 @@ void PresetCollection::set_sync_info_and_save(std::string name, std::string sett
|
||||||
preset->setting_id = setting_id;
|
preset->setting_id = setting_id;
|
||||||
if (update_time > 0)
|
if (update_time > 0)
|
||||||
preset->updated_time = update_time;
|
preset->updated_time = update_time;
|
||||||
preset->sync_info == "update" ? preset->save(nullptr) : preset->save_info();
|
if (preset->sync_info == "update")
|
||||||
|
preset->save(nullptr);
|
||||||
|
else
|
||||||
|
preset->save_info();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public:
|
||||||
|
|
||||||
//BBS: add logic for only difference save
|
//BBS: add logic for only difference save
|
||||||
//if parent_config is null, save all keys, otherwise, only save difference
|
//if parent_config is null, save all keys, otherwise, only save difference
|
||||||
void save(DynamicPrintConfig* parent_config);
|
bool save(DynamicPrintConfig* parent_config);
|
||||||
void reload(Preset const & parent);
|
void reload(Preset const & parent);
|
||||||
|
|
||||||
// Return a label of this preset, consisting of a name and a "(modified)" suffix, if this preset is dirty.
|
// Return a label of this preset, consisting of a name and a "(modified)" suffix, if this preset is dirty.
|
||||||
|
|
Loading…
Reference in New Issue