X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fcopy_to_drive_job.cc;h=0fb41f85642cb3a6fa26929376c4080f2ad51adb;hp=8a8073ec21e505e37906718c5d02c6b772b08224;hb=6ef1fc5f40567650ca9ef2b7644e4fdd97640ae6;hpb=6d27b49a7a767a9c8b31dc0f799da940ddb7232f diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index 8a8073ec2..0fb41f856 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -22,6 +22,7 @@ #include "copy_to_drive_job.h" #include "compose.hpp" #include "exceptions.h" +#include "dcpomatic_log.h" #include #include #include @@ -64,11 +65,18 @@ CopyToDriveJob::json_name () const void 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)) { throw CommunicationFailedError (); } - bool formatting = false; + enum State { + SETUP, + FORMAT, + COPY, + VERIFY + } state = SETUP; + while (true) { optional s = _nanomsg.receive (10000); if (!s) { @@ -82,13 +90,22 @@ CopyToDriveJob::run () optional 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"); + sub (_("Formatting drive")); set_progress_unknown (); - formatting = true; - } else if (*s == DISK_WRITER_PROGRESS) { - if (formatting) { - sub ("Copying DCP"); - formatting = false; + state = FORMAT; + } else if (*s == DISK_WRITER_COPY_PROGRESS) { + if (state == FORMAT) { + sub (_("Copying DCP")); + state = COPY; + } + optional progress = _nanomsg.receive (500); + if (progress) { + set_progress (raw_convert(*progress)); + } + } else if (*s == DISK_WRITER_VERIFY_PROGRESS) { + if (state == COPY) { + sub (_("Verifying copied files")); + state = VERIFY; } optional progress = _nanomsg.receive (500); if (progress) {