From a2f8e8839f276bc83d5926983ab2d38e0a36f927 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 23 Dec 2021 23:33:56 +0100 Subject: [PATCH] Extract simple_digest(). --- src/lib/content.cc | 6 +----- src/lib/util.cc | 7 +++++++ src/lib/util.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/content.cc b/src/lib/content.cc index 3c3942aa1..ed0e9af6d 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(boost::filesystem::file_size(p.front())); + return simple_digest (paths()); } diff --git a/src/lib/util.cc b/src/lib/util.cc index 7106cc782..6e2a1ad64 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -530,6 +530,13 @@ digest_head_tail (vector files, boost::uintmax_t size) } +string +simple_digest (vector paths) +{ + return digest_head_tail(paths, 1000000) + raw_convert(boost::filesystem::file_size(paths.front())); +} + + /** Trip an assert if the caller is not in the UI thread */ void ensure_ui_thread () diff --git a/src/lib/util.h b/src/lib/util.h index e335434d8..706056cda 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -91,6 +91,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::uintmax_t size); +extern std::string simple_digest (std::vector paths); extern void ensure_ui_thread (); extern std::string audio_channel_name (int); extern std::string short_audio_channel_name (int); -- 2.30.2