fix of #6588 - using same copy function for updating presets as for exporting gcode
This commit is contained in:
parent
85d4e1c60b
commit
77e25c5022
@ -56,16 +56,15 @@ static const char *TMP_EXTENSION = ".download";
|
|||||||
|
|
||||||
void copy_file_fix(const fs::path &source, const fs::path &target)
|
void copy_file_fix(const fs::path &source, const fs::path &target)
|
||||||
{
|
{
|
||||||
static const auto perms = fs::owner_read | fs::owner_write | fs::group_read | fs::others_read; // aka 644
|
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << format("PresetUpdater: Copying %1% -> %2%", source, target);
|
BOOST_LOG_TRIVIAL(debug) << format("PresetUpdater: Copying %1% -> %2%", source, target);
|
||||||
|
std::string error_message;
|
||||||
// Make sure the file has correct permission both before and after we copy over it
|
CopyFileResult cfr = copy_file(source.string(), target.string(), error_message, false);
|
||||||
if (fs::exists(target)) {
|
if (cfr != CopyFileResult::SUCCESS) {
|
||||||
fs::permissions(target, perms);
|
BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message;
|
||||||
|
throw Slic3r::CriticalException(GUI::format(
|
||||||
|
_L("Copying of file %1% to %2% failed: %3%"),
|
||||||
|
source, target, error_message));
|
||||||
}
|
}
|
||||||
fs::copy_file(source, target, fs::copy_option::overwrite_if_exists);
|
|
||||||
fs::permissions(target, perms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Update
|
struct Update
|
||||||
|
Loading…
Reference in New Issue
Block a user