Add asset_hashes_can_differ option to the equality checks.
[libdcp.git] / src / asset.cc
index c164a26b75d3aaf1def0af5fdb0b800e849315f6..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;
@@ -158,7 +162,21 @@ void
 Asset::set_file (path file) const
 {
        _file = absolute (file);
-       _hash = boost::optional<string>();
+       _hash = optional<string>();
+}
+
+
+void
+Asset::set_file_preserving_hash(path file) const
+{
+       _file = absolute(file);
+}
+
+
+void
+Asset::rename_file(path file)
+{
+       _file = absolute(file);
 }
 
 
@@ -167,3 +185,11 @@ Asset::set_hash (string hash)
 {
        _hash = hash;
 }
+
+
+void
+Asset::unset_hash()
+{
+       _hash = optional<string>();
+}
+