X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_disk.cc;h=3daffb72d0b94d7d8b0c1b340f4d1359bcaa2c3f;hb=472959c1357f43e2eb33366c58bed0466474c2b7;hp=5ae5cfb927168fb455d7cc8f173395835331c264;hpb=adcf6f9adcd8b33fd6f3cf0e5b00a4a4db183002;p=dcpomatic.git diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 5ae5cfb92..3daffb72d 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -19,22 +19,23 @@ */ -#include "wx/wx_signal_manager.h" -#include "wx/wx_util.h" -#include "wx/job_manager_view.h" +#include "wx/disk_warning_dialog.h" #include "wx/drive_wipe_warning_dialog.h" -#include "wx/try_unmount_dialog.h" +#include "wx/job_manager_view.h" #include "wx/message_dialog.h" -#include "wx/disk_warning_dialog.h" -#include "lib/file_log.h" -#include "lib/dcpomatic_log.h" -#include "lib/util.h" +#include "wx/try_unmount_dialog.h" +#include "wx/wx_util.h" +#include "wx/wx_signal_manager.h" +#include "wx/wx_util.h" #include "lib/config.h" -#include "lib/signal_manager.h" -#include "lib/cross.h" #include "lib/copy_to_drive_job.h" -#include "lib/job_manager.h" +#include "lib/cross.h" +#include "lib/dcpomatic_log.h" #include "lib/disk_writer_messages.h" +#include "lib/file_log.h" +#include "lib/job_manager.h" +#include "lib/signal_manager.h" +#include "lib/util.h" #include "lib/version.h" #include "lib/warnings.h" #include @@ -49,11 +50,12 @@ DCPOMATIC_ENABLE_WARNINGS #endif -using std::string; -using std::exception; -using std::cout; using std::cerr; +using std::cout; +using std::exception; +using std::make_shared; using std::shared_ptr; +using std::string; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; @@ -237,16 +239,37 @@ private: void copy () { + /* Check that the selected drive still exists and update its properties if so */ + drive_refresh (); + if (_drive->GetSelection() == wxNOT_FOUND) { + error_dialog (this, _("The disk you selected is no longer available. Please choose another.")); + return; + } + DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND); DCPOMATIC_ASSERT (static_cast(_dcp_path)); - bool have_writer = true; - if (!_nanomsg.send(DISK_WRITER_PING "\n", 2000)) { - have_writer = false; - } else { - auto reply = _nanomsg.receive (2000); - if (!reply || *reply != DISK_WRITER_PONG) { - have_writer = false; + auto ping = [this](int attempt) { + if (_nanomsg.send(DISK_WRITER_PING "\n", 2000)) { + auto reply = _nanomsg.receive (2000); + if (reply && *reply == DISK_WRITER_PONG) { + return true; + } else if (reply) { + LOG_DISK("Unexpected response %1 to ping received (attempt %2)", *reply, attempt); + } else { + LOG_DISK("No reply received from ping (attempt %1)", attempt); + } + } else { + LOG_DISK("Could not send ping to writer (attempt %1)", attempt); + } + return false; + }; + + bool have_writer = false; + for (int i = 0; i < 8; ++i) { + if (ping(i + 1)) { + have_writer = true; + break; } } @@ -261,6 +284,7 @@ private: m->Destroy (); return; #else + LOG_DISK_NC ("Failed to ping writer"); throw CommunicationFailedError (); #endif } @@ -276,12 +300,15 @@ private: LOG_DISK("Sending unmount request to disk writer for %1", drive.as_xml()); if (!_nanomsg.send(DISK_WRITER_UNMOUNT "\n", 2000)) { + LOG_DISK_NC("Failed to send unmount request."); throw CommunicationFailedError (); } if (!_nanomsg.send(drive.as_xml(), 2000)) { + LOG_DISK_NC("Failed to send drive for unmount request."); throw CommunicationFailedError (); } - auto reply = _nanomsg.receive (2000); + /* The reply may have to wait for the user to authenticate, so let's wait a while */ + auto reply = _nanomsg.receive (30000); if (!reply || *reply != DISK_WRITER_OK) { auto * m = new MessageDialog ( this,