X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fscp_dcp_job.cc;h=63784081356e9eb0fc4d81ea97d551a7078e224d;hb=0da7c88a1afb221f97e2e96c159b1a984e4e2f71;hp=528d393a36d73e559e0ca8b9d45b1e973ea87a3a;hpb=2f25d1608356bf124e502c6aa438ec664c53de80;p=dcpomatic.git diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc index 528d393a3..637840813 100644 --- a/src/lib/scp_dcp_job.cc +++ b/src/lib/scp_dcp_job.cc @@ -33,9 +33,12 @@ #include "config.h" #include "log.h" #include "film.h" +#include "cross.h" #include "i18n.h" +#define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_GENERAL); + using std::string; using std::stringstream; using std::min; @@ -109,10 +112,16 @@ SCPDCPJob::name () const return _("Copy DCP to TMS"); } +string +SCPDCPJob::json_name () const +{ + return N_("scp_dcp"); +} + void SCPDCPJob::run () { - _film->log()->log (N_("SCP DCP job starting")); + LOG_GENERAL_NC (N_("SCP DCP job starting")); SSHSession ss; @@ -150,7 +159,7 @@ SCPDCPJob::run () throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), _film->dcp_name(), ssh_get_error (ss.session))); } - string const dcp_dir = _film->dir (_film->dcp_name()); + boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name()); boost::uintmax_t bytes_to_transfer = 0; for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) { @@ -170,7 +179,7 @@ SCPDCPJob::run () boost::uintmax_t to_do = boost::filesystem::file_size (*i); ssh_scp_push_file (sc.scp, leaf.c_str(), to_do, S_IRUSR | S_IWUSR); - FILE* f = fopen (boost::filesystem::path (*i).string().c_str(), N_("rb")); + FILE* f = fopen_boost (boost::filesystem::path (*i), "rb"); if (f == 0) { throw NetworkError (String::compose (_("Could not open %1 to send"), *i)); } @@ -190,8 +199,10 @@ SCPDCPJob::run () } to_do -= t; bytes_transferred += t; - - set_progress ((double) bytes_transferred / bytes_to_transfer); + + if (bytes_to_transfer > 0) { + set_progress ((double) bytes_transferred / bytes_to_transfer); + } } fclose (f); @@ -220,4 +231,3 @@ SCPDCPJob::set_status (string s) boost::mutex::scoped_lock lm (_status_mutex); _status = s; } -