mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 23:23:59 -06:00
FIX: handle printer file downalod failure
Change-Id: I1e8cbf4a6d4081270ed78bf7d1471eb1d6114a0b
This commit is contained in:
parent
5a0f9ff4f0
commit
448e3b8a8b
3 changed files with 18 additions and 3 deletions
|
@ -278,7 +278,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
||||||
case PrinterFileSystem::ListSyncing: icon = m_bmp_loading; msg = _L("Loading file list..."); break;
|
case PrinterFileSystem::ListSyncing: icon = m_bmp_loading; msg = _L("Loading file list..."); break;
|
||||||
case PrinterFileSystem::ListReady: icon = extra == 0 ? m_bmp_empty : m_bmp_failed; msg = extra == 0 ? _L("No files [%d]") : _L("Load failed [%d]"); break;
|
case PrinterFileSystem::ListReady: icon = extra == 0 ? m_bmp_empty : m_bmp_failed; msg = extra == 0 ? _L("No files [%d]") : _L("Load failed [%d]"); break;
|
||||||
}
|
}
|
||||||
if (!e.GetString().IsEmpty()) msg = _L(e.GetString());
|
if (!e.GetString().IsEmpty()) msg = e.GetString();
|
||||||
if (fs->GetCount() == 0 && !msg.empty())
|
if (fs->GetCount() == 0 && !msg.empty())
|
||||||
m_image_grid->SetStatus(icon, msg);
|
m_image_grid->SetStatus(icon, msg);
|
||||||
if (e.GetInt() == PrinterFileSystem::Initializing)
|
if (e.GetInt() == PrinterFileSystem::Initializing)
|
||||||
|
|
|
@ -19,6 +19,16 @@
|
||||||
//#define PRINTER_FILE_SYSTEM_TEST
|
//#define PRINTER_FILE_SYSTEM_TEST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string last_system_error() {
|
||||||
|
return std::error_code(
|
||||||
|
#ifdef _WIN32
|
||||||
|
GetLastError(),
|
||||||
|
#else
|
||||||
|
errno,
|
||||||
|
#endif
|
||||||
|
std::system_category()).message();
|
||||||
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(EVT_STATUS_CHANGED, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_STATUS_CHANGED, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_MODE_CHANGED, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_MODE_CHANGED, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_FILE_CHANGED, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_FILE_CHANGED, wxCommandEvent);
|
||||||
|
@ -628,6 +638,7 @@ void PrinterFileSystem::DownloadNextFile()
|
||||||
prog.total = resp["total"];
|
prog.total = resp["total"];
|
||||||
if (prog.size == 0) {
|
if (prog.size == 0) {
|
||||||
download->ofs.open(download->local_path, std::ios::binary);
|
download->ofs.open(download->local_path, std::ios::binary);
|
||||||
|
wxLogWarning("PrinterFileSystem::DownloadNextFile open error: %s\n", wxString::FromUTF8(last_system_error()));
|
||||||
if (!download->ofs) return FILE_OPEN_ERR;
|
if (!download->ofs) return FILE_OPEN_ERR;
|
||||||
}
|
}
|
||||||
if (download->total && (download->size != prog.size || download->total != prog.total)) {
|
if (download->total && (download->size != prog.size || download->total != prog.total)) {
|
||||||
|
@ -635,6 +646,10 @@ void PrinterFileSystem::DownloadNextFile()
|
||||||
}
|
}
|
||||||
// receive data
|
// receive data
|
||||||
download->ofs.write((char const *) data, size);
|
download->ofs.write((char const *) data, size);
|
||||||
|
if (!download->ofs) {
|
||||||
|
wxLogWarning("PrinterFileSystem::DownloadNextFile write error: %s\n", wxString::FromUTF8(last_system_error()));
|
||||||
|
return FILE_READ_WRITE_ERR;
|
||||||
|
}
|
||||||
download->boost_md5.process_bytes(data, size);
|
download->boost_md5.process_bytes(data, size);
|
||||||
prog.size += size;
|
prog.size += size;
|
||||||
download->total = prog.total;
|
download->total = prog.total;
|
||||||
|
@ -993,7 +1008,7 @@ void PrinterFileSystem::SendChangedEvent(wxEventType type, size_t index, std::st
|
||||||
if (!str.empty())
|
if (!str.empty())
|
||||||
event.SetString(wxString::FromUTF8(str.c_str()));
|
event.SetString(wxString::FromUTF8(str.c_str()));
|
||||||
else if (auto iter = error_messages.find(extra); iter != error_messages.end())
|
else if (auto iter = error_messages.find(extra); iter != error_messages.end())
|
||||||
event.SetString(wxString::FromUTF8(iter->second.c_str()));
|
event.SetString(_L(iter->second.c_str()));
|
||||||
event.SetExtraLong(extra);
|
event.SetExtraLong(extra);
|
||||||
if (wxThread::IsMain())
|
if (wxThread::IsMain())
|
||||||
ProcessEventLocally(event);
|
ProcessEventLocally(event);
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
FILE_NAME_INVALID = 11,
|
FILE_NAME_INVALID = 11,
|
||||||
FILE_SIZE_ERR = 12,
|
FILE_SIZE_ERR = 12,
|
||||||
FILE_OPEN_ERR = 13,
|
FILE_OPEN_ERR = 13,
|
||||||
FILE_READ_ERR = 14,
|
FILE_READ_WRITE_ERR = 14,
|
||||||
FILE_CHECK_ERR = 15,
|
FILE_CHECK_ERR = 15,
|
||||||
FILE_TYPE_ERR = 16,
|
FILE_TYPE_ERR = 16,
|
||||||
STORAGE_UNAVAILABLE = 17,
|
STORAGE_UNAVAILABLE = 17,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue