X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcopy_to_drive_job.cc;h=c6f9c84b0cea67867ad9f6cc8835a6aae4cfea16;hb=704e1112538d809fd55bd7f25385eaa5d064966c;hp=96f873cf61e75d99ccb659ff544cfb1485191463;hpb=7981eefcfebb563ccf5627f132abdfdef22e0c23;p=dcpomatic.git diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index 96f873cf6..c6f9c84b0 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -18,44 +18,53 @@ */ -#include "disk_writer_messages.h" -#include "copy_to_drive_job.h" + #include "compose.hpp" -#include "exceptions.h" +#include "copy_to_drive_job.h" #include "dcpomatic_log.h" +#include "disk_writer_messages.h" +#include "exceptions.h" #include #include -#include #include +#include +#include #include #include #include -#include #include "i18n.h" -using std::string; + using std::cout; using std::min; using std::shared_ptr; +using std::string; using boost::optional; using dcp::raw_convert; -CopyToDriveJob::CopyToDriveJob (boost::filesystem::path dcp, Drive drive, Nanomsg& nanomsg) + +CopyToDriveJob::CopyToDriveJob(std::vector const& dcps, Drive drive, Nanomsg& nanomsg) : Job (shared_ptr()) - , _dcp (dcp) + , _dcps (dcps) , _drive (drive) , _nanomsg (nanomsg) { } + string CopyToDriveJob::name () const { - return String::compose (_("Copying %1\nto %2"), _dcp.filename().string(), _drive.description()); + if (_dcps.size() == 1) { + return String::compose(_("Copying %1\nto %2"), _dcps[0].filename().string(), _drive.description()); + } + + return String::compose(_("Copying DCPs to %1"), _drive.description()); } + string CopyToDriveJob::json_name () const { @@ -65,8 +74,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)) { + LOG_DISK("Sending write requests to disk %1 for:", _drive.device()); + for (auto dcp: _dcps) { + LOG_DISK("%1", dcp.string()); + } + + string request = String::compose(DISK_WRITER_WRITE "\n%1\n", _drive.device()); + for (auto dcp: _dcps) { + request += String::compose("%1\n", dcp.string()); + } + request += "\n"; + if (!_nanomsg.send(request, 2000)) { + LOG_DISK_NC("Failed to send write request."); throw CommunicationFailedError (); }