X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fcheck_content_change_job.cc;h=16ef8d86485391bb6724eb190055f4fdb94ce6d2;hb=af85c3bb844599895eda780083fb9466cdfc8e76;hp=bb3674f27b42471fa1518f04abd8508ae7a1db9d;hpb=f30bd5d2355bc02d1b5c7772241e191b60028dd2;p=dcpomatic.git diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index bb3674f27..16ef8d864 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -18,20 +18,22 @@ */ + #include "check_content_change_job.h" -#include "job_manager.h" -#include "examine_content_job.h" #include "content.h" +#include "examine_content_job.h" #include "film.h" -#include +#include "job_manager.h" #include #include "i18n.h" -using std::string; -using std::list; + using std::cout; -using boost::shared_ptr; +using std::make_shared; +using std::shared_ptr; +using std::string; + CheckContentChangeJob::CheckContentChangeJob (shared_ptr film) : Job (film) @@ -39,10 +41,15 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr film) } +CheckContentChangeJob::~CheckContentChangeJob () +{ + stop_thread (); +} + string CheckContentChangeJob::name () const { - return _("Check content for changes"); + return _("Checking content for changes"); } string @@ -56,30 +63,15 @@ CheckContentChangeJob::run () { set_progress_unknown (); - list > changed; - - BOOST_FOREACH (shared_ptr i, _film->content()) { - bool ic = false; - for (size_t j = 0; j < i->number_of_paths(); ++j) { - if (boost::filesystem::last_write_time(i->path(j)) != i->last_write_time(j)) { - ic = true; - break; - } - } - if (!ic && i->calculate_digest() != i->digest()) { - ic = true; - } - if (ic) { - changed.push_back (i); - } - } - - BOOST_FOREACH (shared_ptr i, changed) { - JobManager::instance()->add(shared_ptr(new ExamineContentJob(_film, i))); - } + auto content = _film->content(); + std::vector> changed; + std::copy_if (content.begin(), content.end(), std::back_inserter(changed), [](shared_ptr c) { return c->changed(); }); if (!changed.empty()) { - set_message (_("Some files were changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings.")); + for (auto i: changed) { + JobManager::instance()->add(make_shared(_film, i)); + } + set_message (_("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings.")); } set_progress (1);