PresetUpdater: Use PID in cache tmp filenames

This commit is contained in:
Vojtech Kral 2018-04-20 11:05:00 +02:00
parent 2e61420747
commit 9b5480b7ba
3 changed files with 22 additions and 3 deletions

View file

@ -62,6 +62,9 @@ extern std::string timestamp_str();
// to be placed at the top of Slic3r generated files. // to be placed at the top of Slic3r generated files.
inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); } inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); }
// getpid platform wrapper
extern unsigned get_current_pid();
// Compute the next highest power of 2 of 32-bit v // Compute the next highest power of 2 of 32-bit v
// http://graphics.stanford.edu/~seander/bithacks.html // http://graphics.stanford.edu/~seander/bithacks.html
template<typename T> template<typename T>

View file

@ -1,6 +1,12 @@
#include <locale> #include <locale>
#include <ctime> #include <ctime>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <boost/log/core.hpp> #include <boost/log/core.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp> #include <boost/log/expressions.hpp>
@ -271,4 +277,13 @@ std::string timestamp_str()
return buf; return buf;
} }
unsigned get_current_pid()
{
#ifdef WIN32
return GetCurrentProcessId();
#else
return ::getpid();
#endif
}
}; // namespace Slic3r }; // namespace Slic3r

View file

@ -180,11 +180,12 @@ void PresetUpdater::priv::set_download_prefs(AppConfig *app_config)
bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const
{ {
std::cerr << "get_file(): " << url << " -> " << target_path << std::endl;
bool res = false; bool res = false;
fs::path tmp_path = target_path; fs::path tmp_path = target_path;
tmp_path += TMP_EXTENSION; tmp_path += (boost::format(".%1%%2%") % get_current_pid() % TMP_EXTENSION).str();
std::cerr << "get_file(): " << url << " -> " << target_path << std::endl
<< "\ttmp_path: " << tmp_path << std::endl;
Http::get(url) Http::get(url)
.on_progress([this](Http::Progress, bool &cancel) { .on_progress([this](Http::Progress, bool &cancel) {