Throwing exceptions with text after copy file check failure and renaming from .tmp failure
This commit is contained in:
parent
5e91bcc91c
commit
93f9fc1049
@ -449,7 +449,7 @@ int copy_file(const std::string &from, const std::string &to, const bool with_ch
|
|||||||
ret_val = check_copy(from, to_temp);
|
ret_val = check_copy(from, to_temp);
|
||||||
|
|
||||||
if (ret_val == 0 && rename_file(to_temp, to))
|
if (ret_val == 0 && rename_file(to_temp, to))
|
||||||
ret_val = -1;
|
ret_val = -3;
|
||||||
}
|
}
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
@ -460,11 +460,11 @@ int check_copy(const std::string &origin, const std::string ©)
|
|||||||
std::ifstream f2(copy, std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
|
std::ifstream f2(copy, std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
|
||||||
|
|
||||||
if (f1.fail() || f2.fail())
|
if (f1.fail() || f2.fail())
|
||||||
return -1;
|
return -2;
|
||||||
|
|
||||||
std::streampos fsize = f1.tellg();
|
std::streampos fsize = f1.tellg();
|
||||||
if (fsize != f2.tellg())
|
if (fsize != f2.tellg())
|
||||||
return -1;
|
return -2;
|
||||||
|
|
||||||
f1.seekg(0, std::ifstream::beg);
|
f1.seekg(0, std::ifstream::beg);
|
||||||
f2.seekg(0, std::ifstream::beg);
|
f2.seekg(0, std::ifstream::beg);
|
||||||
@ -481,12 +481,12 @@ int check_copy(const std::string &origin, const std::string ©)
|
|||||||
if (origin_cnt != copy_cnt ||
|
if (origin_cnt != copy_cnt ||
|
||||||
(origin_cnt > 0 && std::memcmp(buffer_origin.data(), buffer_copy.data(), origin_cnt) != 0))
|
(origin_cnt > 0 && std::memcmp(buffer_origin.data(), buffer_copy.data(), origin_cnt) != 0))
|
||||||
// Files are different.
|
// Files are different.
|
||||||
return -1;
|
return -2;
|
||||||
fsize -= origin_cnt;
|
fsize -= origin_cnt;
|
||||||
} while (f1.good() && f2.good());
|
} while (f1.good() && f2.good());
|
||||||
|
|
||||||
// All data has been read and compared equal.
|
// All data has been read and compared equal.
|
||||||
return (f1.eof() && f2.eof() && fsize == 0) ? 0 : -1;
|
return (f1.eof() && f2.eof() && fsize == 0) ? 0 : -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore system and hidden files, which may be created by the DropBox synchronisation process.
|
// Ignore system and hidden files, which may be created by the DropBox synchronisation process.
|
||||||
|
@ -100,8 +100,23 @@ void BackgroundSlicingProcess::process_fff()
|
|||||||
//FIXME localize the messages
|
//FIXME localize the messages
|
||||||
// Perform the final post-processing of the export path by applying the print statistics over the file name.
|
// 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);
|
std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path);
|
||||||
if (copy_file(m_temp_output_path, export_path, GUI::RemovableDriveManager::get_instance().is_path_on_removable_drive(export_path)) != 0)
|
GUI::RemovableDriveManager::get_instance().update();
|
||||||
|
bool with_check = GUI::RemovableDriveManager::get_instance().is_path_on_removable_drive(export_path);
|
||||||
|
int copy_ret_val = copy_file(m_temp_output_path, export_path, with_check);
|
||||||
|
if (with_check && copy_ret_val == -2)
|
||||||
|
{
|
||||||
|
std::string err_msg = "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 " + export_path + ".tmp.";
|
||||||
|
throw std::runtime_error(_utf8(L(err_msg)));
|
||||||
|
}
|
||||||
|
else if (copy_ret_val == -3)
|
||||||
|
{
|
||||||
|
std::string err_msg = "Renaming of the G-code after copying to the selected destination folder has failed. Current path is " + export_path + ".tmp. Please try exporting again.";
|
||||||
|
throw std::runtime_error(_utf8(L(err_msg)));
|
||||||
|
}
|
||||||
|
else if ( copy_ret_val != 0)
|
||||||
|
{
|
||||||
throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?")));
|
throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?")));
|
||||||
|
}
|
||||||
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
|
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
|
||||||
run_post_process_scripts(export_path, m_fff_print->config());
|
run_post_process_scripts(export_path, m_fff_print->config());
|
||||||
m_print->set_status(100, (boost::format(_utf8(L("G-code file exported to %1%"))) % export_path).str());
|
m_print->set_status(100, (boost::format(_utf8(L("G-code file exported to %1%"))) % export_path).str());
|
||||||
|
Loading…
Reference in New Issue
Block a user