summaryrefslogtreecommitdiff
path: root/src/lib/content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-08-21 22:36:24 +0100
committerCarl Hetherington <cth@carlh.net>2018-08-21 22:36:24 +0100
commitf968fb875135884b0551195edc2315d4be76d5bc (patch)
treea7a7c0f4a68a86b41e14206d6b2839011fddc4bb /src/lib/content.cc
parent3734060fc1c7db2d1bdb44ff59eece4d1df6cad6 (diff)
Check content for changes on loading a project.
Diffstat (limited to 'src/lib/content.cc')
-rw-r--r--src/lib/content.cc24
1 files changed, 15 insertions, 9 deletions
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<const Film> film, cxml::ConstNodePtr node)
list<cxml::NodePtr> path_children = node->node_children ("Path");
BOOST_FOREACH (cxml::NodePtr i, path_children) {
_paths.push_back (i->content());
- optional<time_t> const mod = i->optional_number_child<time_t>("mtime");
+ optional<time_t> const mod = i->optional_number_attribute<time_t>("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> job)
+string
+Content::calculate_digest () const
{
- if (job) {
- job->sub (_("Computing digest"));
- }
-
boost::mutex::scoped_lock lm (_mutex);
vector<boost::filesystem::path> p = _paths;
lm.unlock ();
@@ -184,9 +180,19 @@ Content::examine (shared_ptr<Job> 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<string> (boost::filesystem::file_size (p.front ()));
+ return digest_head_tail(p, 1000000) + raw_convert<string>(boost::filesystem::file_size(p.front()));
+}
- lm.lock ();
+void
+Content::examine (shared_ptr<Job> job)
+{
+ if (job) {
+ job->sub (_("Computing digest"));
+ }
+
+ string const d = calculate_digest ();
+
+ boost::mutex::scoped_lock lm (_mutex);
_digest = d;
}