From 5352daa4fa25f2ec3353ace953d23d9cb09f3549 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Aug 2013 16:11:29 +0100 Subject: Tidy up content mutexes slightly. --- src/lib/content.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/lib/content.cc') diff --git a/src/lib/content.cc b/src/lib/content.cc index 950814491..44b52a471 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -71,6 +71,7 @@ void Content::as_xml (xmlpp::Node* node) const { boost::mutex::scoped_lock lm (_mutex); + node->add_child("Path")->add_child_text (_path.string()); node->add_child("Digest")->add_child_text (_digest); node->add_child("Position")->add_child_text (lexical_cast (_position)); @@ -81,14 +82,18 @@ Content::as_xml (xmlpp::Node* node) const void Content::examine (shared_ptr) { + boost::mutex::scoped_lock lm (_mutex); + boost::filesystem::path p = _path; + lm.unlock (); + string d; - if (boost::filesystem::is_regular_file (_path)) { - d = md5_digest (_path); + if (boost::filesystem::is_regular_file (p)) { + d = md5_digest (p); } else { - d = md5_digest_directory (_path); + d = md5_digest_directory (p); } - - boost::mutex::scoped_lock lm (_mutex); + + lm.lock (); _digest = d; } @@ -158,7 +163,7 @@ Content::technical_summary () const Time Content::length_after_trim () const { - return full_length () - _trim_start - _trim_end; + return full_length() - trim_start() - trim_end(); } /** @param t A time relative to the start of this content (not the position). -- cgit v1.2.3