Add asset_hashes_can_differ option to the equality checks. v1.8.74
authorCarl Hetherington <cth@carlh.net>
Wed, 28 Jun 2023 21:00:57 +0000 (23:00 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 28 Jun 2023 23:25:46 +0000 (01:25 +0200)
Before recent changes Asset::_hash would be empty when the equality
checks were run (and Asset::equals() compares them directly).

This mean that differences in asset hash were being ignored, but
are no longer; so now we need this option to restore that behaviour
where required.

src/asset.cc
src/types.h

index d88c690d20fc906f693a570411ba847a181865a6..330bd653082fcb1ff6441322b06c640ee76f7ca7 100644 (file)
@@ -143,11 +143,15 @@ Asset::hash (function<void (float)> progress) const
 
 
 bool
-Asset::equals (std::shared_ptr<const Asset> other, EqualityOptions, NoteHandler note) const
+Asset::equals(std::shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
 {
        if (_hash != other->_hash) {
-               note (NoteType::ERROR, "Asset: hashes differ");
-               return false;
+               if (!opt.asset_hashes_can_differ) {
+                       note(NoteType::ERROR, "Asset: hashes differ");
+                       return false;
+               } else {
+                       note(NoteType::NOTE, "Asset: hashes differ");
+               }
        }
 
        return true;
index a670fdd592a4218fd0b8613efe5a6351fd25e856..87d7ffc8a93271e7e40c669261b7345eb8e2d5af 100644 (file)
@@ -254,6 +254,8 @@ struct EqualityOptions
        bool reel_annotation_texts_can_differ = false;
        /** true if <Hash>es in Reels can differ */
        bool reel_hashes_can_differ = false;
+       /** true if asset hashes can differ */
+       bool asset_hashes_can_differ = false;
        /** true if IssueDate nodes can differ */
        bool issue_dates_can_differ = false;
        bool load_font_nodes_can_differ = false;