X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcopy_to_drive_job.cc;h=9ddedfe62dfc8c946f38a1fd7a65755bf8bccd7d;hb=ccacce39c39d16977ab6c1592fcb6e941b05ddff;hp=f78d3d3c511b5b8d6f830cefe11a5733635a538d;hpb=f18a6eca3631dcced7b2ff6d3d22afdb51499843;p=dcpomatic.git diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index f78d3d3c5..9ddedfe62 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -37,7 +37,7 @@ using std::string; using std::cout; using std::min; -using boost::shared_ptr; +using std::shared_ptr; using boost::optional; using dcp::raw_convert; @@ -67,6 +67,7 @@ CopyToDriveJob::run () { LOG_DISK("Sending write request to disk writer for %1 %2", _dcp.string(), _drive.device()); if (!_nanomsg.send(String::compose(DISK_WRITER_WRITE "\n%1\n%2\n", _dcp.string(), _drive.device()), 2000)) { + LOG_DISK_NC("Failed to send write request."); throw CommunicationFailedError (); } @@ -86,19 +87,24 @@ CopyToDriveJob::run () set_state (FINISHED_OK); return; } else if (*s == DISK_WRITER_ERROR) { - optional const m = _nanomsg.receive (500); - optional const n = _nanomsg.receive (500); + auto const m = _nanomsg.receive (500); + auto const n = _nanomsg.receive (500); throw CopyError (m.get_value_or("Unknown"), raw_convert(n.get_value_or("0"))); - } else if (*s == DISK_WRITER_FORMATTING) { - sub (_("Formatting drive")); - set_progress_unknown (); - state = FORMAT; + } else if (*s == DISK_WRITER_FORMAT_PROGRESS) { + if (state == SETUP) { + sub (_("Formatting drive")); + state = FORMAT; + } + auto progress = _nanomsg.receive (500); + if (progress) { + set_progress (raw_convert(*progress)); + } } else if (*s == DISK_WRITER_COPY_PROGRESS) { if (state == FORMAT) { sub (_("Copying DCP")); state = COPY; } - optional progress = _nanomsg.receive (500); + auto progress = _nanomsg.receive (500); if (progress) { set_progress (raw_convert(*progress)); } @@ -107,7 +113,7 @@ CopyToDriveJob::run () sub (_("Verifying copied files")); state = VERIFY; } - optional progress = _nanomsg.receive (500); + auto progress = _nanomsg.receive (500); if (progress) { set_progress (raw_convert(*progress)); }