summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-12-23 23:33:56 +0100
committerCarl Hetherington <cth@carlh.net>2021-12-25 02:07:56 +0100
commit9da422177392fb9e036bf6ead51f71ee6f3b7d9c (patch)
tree9b516d910d5e9ba74383ccfc4f41725cec8af0f1 /src/lib
parent9f666a0f0191406ef444b48916ae4bb15bd1fca1 (diff)
Extract simple_digest().
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content.cc6
-rw-r--r--src/lib/util.cc8
-rw-r--r--src/lib/util.h1
3 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 5b5f0753c..2292c1f9d 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -169,15 +169,11 @@ Content::as_xml (xmlpp::Node* node, bool with_paths) const
string
Content::calculate_digest () const
{
- boost::mutex::scoped_lock lm (_mutex);
- auto p = _paths;
- lm.unlock ();
-
/* Some content files are very big, so we use a poor man's
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.
*/
- return digest_head_tail(p, 1000000) + raw_convert<string>(boost::filesystem::file_size(p.front()));
+ return simple_digest (paths());
}
diff --git a/src/lib/util.cc b/src/lib/util.cc
index c165a5129..64fdd6a37 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -529,6 +529,14 @@ digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
return digester.get ();
}
+
+string
+simple_digest (vector<boost::filesystem::path> paths)
+{
+ return digest_head_tail(paths, 1000000) + raw_convert<string>(boost::filesystem::file_size(paths.front()));
+}
+
+
/** Round a number up to the nearest multiple of another number.
* @param c Index.
* @param stride Array of numbers to round, indexed by c.
diff --git a/src/lib/util.h b/src/lib/util.h
index 10c5678ff..1296dc789 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -94,6 +94,7 @@ extern void dcpomatic_setup ();
extern void dcpomatic_setup_path_encoding ();
extern void dcpomatic_setup_gettext_i18n (std::string);
extern std::string digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
+extern std::string simple_digest (std::vector<boost::filesystem::path> paths);
extern void ensure_ui_thread ();
extern std::string audio_channel_name (int);
extern std::string short_audio_channel_name (int);