summaryrefslogtreecommitdiff
path: root/src/lib/content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-08-14 16:11:29 +0100
committerCarl Hetherington <cth@carlh.net>2013-08-14 16:11:29 +0100
commit5352daa4fa25f2ec3353ace953d23d9cb09f3549 (patch)
tree56d44e07e84ff5d689097b5b2829e9bd697702d9 /src/lib/content.cc
parenta5a64cf04a5b87296abd2a04306a907767f02e56 (diff)
Tidy up content mutexes slightly.
Diffstat (limited to 'src/lib/content.cc')
-rw-r--r--src/lib/content.cc17
1 files changed, 11 insertions, 6 deletions
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<string> (_position));
@@ -81,14 +82,18 @@ Content::as_xml (xmlpp::Node* node) const
void
Content::examine (shared_ptr<Job>)
{
+ 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).