Merge branch 'dk_eject'
This commit is contained in:
commit
454b26c672
@ -75,11 +75,12 @@ enum CopyFileResult {
|
||||
FAIL_CHECK_TARGET_NOT_OPENED
|
||||
};
|
||||
// Copy a file, adjust the access attributes, so that the target is writable.
|
||||
CopyFileResult copy_file_inner(const std::string &from, const std::string &to, boost::system::error_code& error_code);
|
||||
CopyFileResult copy_file_inner(const std::string &from, const std::string &to, std::string& error_message);
|
||||
// Copy file to a temp file first, then rename it to the final file name.
|
||||
// If with_check is true, then the content of the copied file is compared to the content
|
||||
// of the source file before renaming.
|
||||
extern CopyFileResult copy_file(const std::string &from, const std::string &to, boost::system::error_code& error_code, const bool with_check = false);
|
||||
// Additional error info is passed in error message.
|
||||
extern CopyFileResult copy_file(const std::string &from, const std::string &to, std::string& error_message, const bool with_check = false);
|
||||
|
||||
// Compares two files if identical.
|
||||
extern CopyFileResult check_copy(const std::string& origin, const std::string& copy);
|
||||
|
@ -417,7 +417,7 @@ std::error_code rename_file(const std::string &from, const std::string &to)
|
||||
#endif
|
||||
}
|
||||
|
||||
CopyFileResult copy_file_inner(const std::string& from, const std::string& to, boost::system::error_code &error_code)
|
||||
CopyFileResult copy_file_inner(const std::string& from, const std::string& to, std::string& error_message)
|
||||
{
|
||||
const boost::filesystem::path source(from);
|
||||
const boost::filesystem::path target(to);
|
||||
@ -434,25 +434,26 @@ CopyFileResult copy_file_inner(const std::string& from, const std::string& to, b
|
||||
boost::system::error_code ec;
|
||||
|
||||
boost::filesystem::permissions(target, perms, ec);
|
||||
if (ec)
|
||||
BOOST_LOG_TRIVIAL(error) << "Copy file permisions before copy error message: " << ec.message();
|
||||
//if (ec)
|
||||
// BOOST_LOG_TRIVIAL(error) << "Copy file permisions before copy error message: " << ec.message();
|
||||
// This error code is passed up
|
||||
error_code.clear();
|
||||
boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, error_code);
|
||||
if (error_code) {
|
||||
ec.clear();
|
||||
boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, ec);
|
||||
if (ec) {
|
||||
error_message = ec.message();
|
||||
return FAIL_COPY_FILE;
|
||||
}
|
||||
ec.clear();
|
||||
//ec.clear();
|
||||
boost::filesystem::permissions(target, perms, ec);
|
||||
if (ec)
|
||||
BOOST_LOG_TRIVIAL(error) << "Copy file permisions after copy error message: " << ec.message();
|
||||
//if (ec)
|
||||
// BOOST_LOG_TRIVIAL(error) << "Copy file permisions after copy error message: " << ec.message();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
CopyFileResult copy_file(const std::string &from, const std::string &to, boost::system::error_code &error_code, const bool with_check)
|
||||
CopyFileResult copy_file(const std::string &from, const std::string &to, std::string& error_message, const bool with_check)
|
||||
{
|
||||
std::string to_temp = to + ".tmp";
|
||||
CopyFileResult ret_val = copy_file_inner(from, to_temp, error_code);
|
||||
CopyFileResult ret_val = copy_file_inner(from, to_temp, error_message);
|
||||
if(ret_val == SUCCESS)
|
||||
{
|
||||
if (with_check)
|
||||
|
@ -137,12 +137,12 @@ void BackgroundSlicingProcess::process_fff()
|
||||
//FIXME localize the messages
|
||||
// Perform the final post-processing of the export path by applying the print statistics over the file name.
|
||||
std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path);
|
||||
boost::system::error_code error_code;
|
||||
int copy_ret_val = copy_file(m_temp_output_path, export_path, error_code, m_export_path_on_removable_media);
|
||||
std::string error_message;
|
||||
int copy_ret_val = copy_file(m_temp_output_path, export_path, error_message, m_export_path_on_removable_media);
|
||||
switch (copy_ret_val) {
|
||||
case SUCCESS: break; // no error
|
||||
case FAIL_COPY_FILE:
|
||||
throw Slic3r::RuntimeError((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%"))) % error_code.message()).str());
|
||||
throw Slic3r::RuntimeError((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%"))) % error_message).str());
|
||||
break;
|
||||
case FAIL_FILES_DIFFERENT:
|
||||
throw Slic3r::RuntimeError((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. There might be problem with target device, please try exporting again or using different device. The corrupted output G-code is at %1%.tmp."))) % export_path).str());
|
||||
@ -157,6 +157,7 @@ void BackgroundSlicingProcess::process_fff()
|
||||
throw Slic3r::RuntimeError((boost::format(_utf8(L("Copying of the temporary G-code has finished but the exported code couldn't be opened during copy check. The output G-code is at %1%.tmp."))) % export_path).str());
|
||||
break;
|
||||
default:
|
||||
throw Slic3r::RuntimeError(_utf8(L("Unknown error occured during exporting G-code.")));
|
||||
BOOST_LOG_TRIVIAL(error) << "Unexpected fail code(" << (int)copy_ret_val << ") durring copy_file() to " << export_path << ".";
|
||||
break;
|
||||
}
|
||||
@ -522,8 +523,8 @@ void BackgroundSlicingProcess::prepare_upload()
|
||||
|
||||
if (m_print == m_fff_print) {
|
||||
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
|
||||
boost::system::error_code error_code;
|
||||
if (copy_file(m_temp_output_path, source_path.string(), error_code) != SUCCESS) {
|
||||
std::string error_message;
|
||||
if (copy_file(m_temp_output_path, source_path.string(), error_message) != SUCCESS) {
|
||||
throw Slic3r::RuntimeError(_utf8(L("Copying of the temporary G-code to the output G-code failed")));
|
||||
}
|
||||
run_post_process_scripts(source_path.string(), m_fff_print->config());
|
||||
|
Loading…
Reference in New Issue
Block a user