Extract simple_digest().
authorCarl Hetherington <cth@carlh.net>
Thu, 23 Dec 2021 22:33:56 +0000 (23:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 25 Dec 2021 01:07:56 +0000 (02:07 +0100)
src/lib/content.cc
src/lib/util.cc
src/lib/util.h

index 5b5f0753cce68548f98f8b94f928c631187522b2..2292c1f9d4109d458046850af5d37321fcb897a3 100644 (file)
@@ -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());
 }
 
 
index c165a5129bae42bfe646b772d56d246a7102935f..64fdd6a37ee24641ff44fe392af536a44e452e37 100644 (file)
@@ -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.
index 10c5678ffd37f72c4b0e37c0d450f18ad950efa3..1296dc78940ccd196d6c5a27015c08dfc38bb5be 100644 (file)
@@ -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);