Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/libslic3r/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,12 +1062,21 @@ std::string Model::get_backup_path()
std::time_t t = std::time(0);
std::tm* now_time = std::localtime(&t);
std::stringstream buf;
buf << "/snapmaker_orca_model/";
buf << std::put_time(now_time, "%a_%b_%d/%H_%M_%S#");
buf << std::put_time(now_time, "%a_%b_%d");
const std::string date_dir = buf.str();
buf.str("");
buf.clear();
buf << std::put_time(now_time, "%H_%M_%S#");
buf << pid << "#";
buf << this->id().id;

backup_path = parent_path.string() + buf.str();
const std::string time_dir = buf.str();

// GH #776: build the path with boost::filesystem::path operators so it
// uses the native separator. The old code concatenated strings with a
// hardcoded "/" onto temporary_dir() (backslashes on Windows), producing
// a mixed-separator path (C:\...\Temp/snapmaker_orca_model/...) that
// Windows/Python post-process scripts choke on.
backup_path = (parent_path / "snapmaker_orca_model" / date_dir / time_dir).string();
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))
Expand All @@ -1081,11 +1090,11 @@ std::string Model::get_backup_path()
if (!boost::filesystem::exists(temp_path))
{
BOOST_LOG_TRIVIAL(info) << "create /3D/Objects in " << temp_path;
boost::filesystem::create_directories(backup_path + "/3D/Objects");
boost::filesystem::create_directories(temp_path / "3D" / "Objects");
BOOST_LOG_TRIVIAL(info) << "create /Metadata in " << temp_path;
boost::filesystem::create_directories(backup_path + "/Metadata");
boost::filesystem::create_directories(temp_path / "Metadata");
BOOST_LOG_TRIVIAL(info) << "create /lock.txt in " << temp_path;
save_string_file(backup_path + "/lock.txt",
save_string_file(temp_path / "lock.txt",
boost::lexical_cast<std::string>(get_current_pid()));
}
} catch (std::exception &ex) {
Expand Down