From f968fb875135884b0551195edc2315d4be76d5bc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Aug 2018 22:36:24 +0100 Subject: Check content for changes on loading a project. --- src/lib/content.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/lib/content.cc') diff --git a/src/lib/content.cc b/src/lib/content.cc index 4e77831ac..69dcbc139 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -97,7 +97,7 @@ Content::Content (shared_ptr film, cxml::ConstNodePtr node) list path_children = node->node_children ("Path"); BOOST_FOREACH (cxml::NodePtr i, path_children) { _paths.push_back (i->content()); - optional const mod = i->optional_number_child("mtime"); + optional const mod = i->optional_number_attribute("mtime"); if (mod) { _last_write_times.push_back (*mod); } else if (boost::filesystem::exists(i->content())) { @@ -169,13 +169,9 @@ Content::as_xml (xmlpp::Node* node, bool with_paths) const } } -void -Content::examine (shared_ptr job) +string +Content::calculate_digest () const { - if (job) { - job->sub (_("Computing digest")); - } - boost::mutex::scoped_lock lm (_mutex); vector p = _paths; lm.unlock (); @@ -184,9 +180,19 @@ Content::examine (shared_ptr job) digest here: a digest of the first and last 1e6 bytes with the size of the first file tacked on the end as a string. */ - string const d = digest_head_tail (p, 1000000) + raw_convert (boost::filesystem::file_size (p.front ())); + return digest_head_tail(p, 1000000) + raw_convert(boost::filesystem::file_size(p.front())); +} - lm.lock (); +void +Content::examine (shared_ptr job) +{ + if (job) { + job->sub (_("Computing digest")); + } + + string const d = calculate_digest (); + + boost::mutex::scoped_lock lm (_mutex); _digest = d; } -- cgit v1.2.3