mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
ENH: backup: add logic to cleanup directory under cli
Change-Id: I7a846e362f45d1c7e34bef59be3b2c312799d0d2
This commit is contained in:
@@ -790,9 +790,11 @@ std::string Model::get_backup_path()
|
||||
buf << this->id().id;
|
||||
|
||||
backup_path = parent_path.string() + buf.str();
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("model %1%, id %2%, backup_path empty, set to %3%")%this%this->id().id%backup_path;
|
||||
boost::filesystem::path temp_path(backup_path);
|
||||
if (boost::filesystem::exists(temp_path))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("model %1%, id %2%, remove previous %3%")%this%this->id().id%backup_path;
|
||||
boost::filesystem::remove_all(temp_path);
|
||||
}
|
||||
}
|
||||
@@ -815,6 +817,19 @@ std::string Model::get_backup_path()
|
||||
return backup_path;
|
||||
}
|
||||
|
||||
void Model::remove_backup_path_if_exist()
|
||||
{
|
||||
if (!backup_path.empty()) {
|
||||
boost::filesystem::path temp_path(backup_path);
|
||||
if (boost::filesystem::exists(temp_path))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("model %1%, id %2% remove backup_path %3%")%this%this->id().id%backup_path;
|
||||
boost::filesystem::remove_all(temp_path);
|
||||
}
|
||||
backup_path.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::string Model::get_backup_path(const std::string &sub_path)
|
||||
{
|
||||
auto path = get_backup_path() + "/" + sub_path;
|
||||
@@ -837,9 +852,12 @@ void Model::set_backup_path(std::string const& path)
|
||||
backup_path.clear();
|
||||
return;
|
||||
}
|
||||
if (!backup_path.empty())
|
||||
if (!backup_path.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<<boost::format(", model %1%, id %2%, remove previous backup %3%")%this%this->id().id%backup_path;
|
||||
Slic3r::remove_backup(*this, true);
|
||||
}
|
||||
backup_path = path;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<<boost::format(", model %1%, id %2%, set backup to %3%")%this%this->id().id%backup_path;
|
||||
}
|
||||
|
||||
void Model::load_from(Model& model)
|
||||
|
||||
Reference in New Issue
Block a user