Try to not start jobs if a dependant fails.
[dcpomatic.git] / src / lib / film.cc
index 90c410546184fe3c86e2db914388f5ae131b119e..00d37c097aec72e676f2cfc485bdf57c3960900d 100644 (file)
@@ -49,6 +49,7 @@
 #include "decoder_factory.h"
 #include "config.h"
 #include "check_hashes_job.h"
+#include "version.h"
 
 using namespace std;
 using namespace boost;
@@ -84,8 +85,12 @@ Film::Film (string d, bool must_exist)
 
        _state.directory = result.string ();
        
-       if (must_exist && !filesystem::exists (_state.directory)) {
-               throw OpenFileError (_state.directory);
+       if (!filesystem::exists (_state.directory)) {
+               if (must_exist) {
+                       throw OpenFileError (_state.directory);
+               } else {
+                       filesystem::create_directory (_state.directory);
+               }
        }
 
        read_metadata ();
@@ -483,7 +488,7 @@ Film::make_dcp (bool transcode, int freq)
                throw BadSettingError ("name", "cannot contain slashes");
        }
        
-       log()->log (String::compose ("DVD-o-matic %1 using %2", DVDOMATIC_VERSION, dependency_version_summary()));
+       log()->log (String::compose ("DVD-o-matic %1 git %2 using %3", dvdomatic_version, dvdomatic_git_commit, dependency_version_summary()));
 
        {
                char buffer[128];
@@ -512,36 +517,35 @@ Film::make_dcp (bool transcode, int freq)
        o->out_size = format()->dcp_size ();
        if (dcp_frames() == 0) {
                /* Decode the whole film, no blacking */
-               o->num_frames = 0;
                o->black_after = 0;
        } else {
                switch (dcp_trim_action()) {
                case CUT:
                        /* Decode only part of the film, no blacking */
-                       o->num_frames = dcp_frames ();
                        o->black_after = 0;
                        break;
                case BLACK_OUT:
                        /* Decode the whole film, but black some frames out */
-                       o->num_frames = 0;
                        o->black_after = dcp_frames ();
                }
        }
        
        o->decode_video_frequency = freq;
-       o->padding = format()->dcp_padding ();
-       o->ratio = format()->ratio_as_float ();
+       o->padding = format()->dcp_padding (this);
+       o->ratio = format()->ratio_as_float (this);
+
+       shared_ptr<Job> r;
 
        if (transcode) {
                if (_state.dcp_ab) {
-                       JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (fs, o, log ())));
+                       r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (fs, o, log(), shared_ptr<Job> ())));
                } else {
-                       JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (fs, o, log ())));
+                       r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (fs, o, log(), shared_ptr<Job> ())));
                }
        }
 
-       JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (fs, o, log ())));
-       JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (fs, o, log ())));
+       r = JobManager::instance()->add (shared_ptr<Job> (new CheckHashesJob (fs, o, log(), r)));
+       JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (fs, o, log(), r)));
 }
 
 shared_ptr<FilmState>
@@ -580,7 +584,7 @@ Film::examine_content ()
                return;
        }
        
-       _examine_content_job.reset (new ExamineContentJob (state_copy (), log ()));
+       _examine_content_job.reset (new ExamineContentJob (state_copy (), log(), shared_ptr<Job> ()));
        _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_post_gui));
        JobManager::instance()->add (_examine_content_job);
 }
@@ -629,14 +633,14 @@ Film::set_still_duration (int d)
 void
 Film::send_dcp_to_tms ()
 {
-       shared_ptr<Job> j (new SCPDCPJob (state_copy (), log ()));
+       shared_ptr<Job> j (new SCPDCPJob (state_copy (), log(), shared_ptr<Job> ()));
        JobManager::instance()->add (j);
 }
 
 void
 Film::copy_from_dvd ()
 {
-       shared_ptr<Job> j (new CopyFromDVDJob (state_copy (), log ()));
+       shared_ptr<Job> j (new CopyFromDVDJob (state_copy (), log(), shared_ptr<Job> ()));
        j->Finished.connect (sigc::mem_fun (*this, &Film::copy_from_dvd_post_gui));
        JobManager::instance()->add (j);
 }