Fix deadlock.
[dcpomatic.git] / src / lib / scp_dcp_job.cc
index e367c9fe8f1ef3a7017e5e6fde8f78784892d006..5aade6382d13b3442dee91ca94f98cb7fad05838 100644 (file)
 #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;
 using boost::shared_ptr;
 
@@ -109,10 +111,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;
        
@@ -190,8 +198,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);
@@ -206,12 +216,11 @@ string
 SCPDCPJob::status () const
 {
        boost::mutex::scoped_lock lm (_status_mutex);
-       stringstream s;
-       s << Job::status ();
+       string s = Job::status ();
        if (!_status.empty ()) {
-               s << N_("; ") << _status;
+               s += N_("; ") + _status;
        }
-       return s.str ();
+       return s;
 }
 
 void
@@ -220,4 +229,3 @@ SCPDCPJob::set_status (string s)
        boost::mutex::scoped_lock lm (_status_mutex);
        _status = s;
 }
-