From e9954920955384da9024bc4f1465ed86b2063f01 Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 22 Jun 2023 21:47:15 +0900 Subject: [PATCH] output: check legacy hash name in output.add() --- dvc/output.py | 8 ++++++-- tests/func/test_add.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index 4e86d6f98..3138fed1b 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -692,8 +692,7 @@ class Output: if self.metric: self.verify_metric() - if self.hash_name == "md5-dos2unix" and self.changed_checksum(): - self.hash_name = "md5" + self._update_legacy_hash_name() if self.use_cache: _, self.meta, self.obj = build( self.cache, @@ -717,6 +716,10 @@ class Output: self.hash_info = self.obj.hash_info self.files = None + def _update_legacy_hash_name(self): + if self.hash_name == "md5-dos2unix" and self.changed_checksum(): + self.hash_name = "md5" + def set_exec(self) -> None: if self.isfile() and self.meta.isexec: self.cache.set_exec(self.fs_path) @@ -1338,6 +1341,7 @@ class Output: ) assert self.repo + self._update_legacy_hash_name() cache = self.cache if self.use_cache else self.local_cache assert isinstance(cache, HashFileDB) diff --git a/tests/func/test_add.py b/tests/func/test_add.py index b4eb776ea..6154d0eee 100644 --- a/tests/func/test_add.py +++ b/tests/func/test_add.py @@ -784,6 +784,7 @@ def test_add_preserve_fields(tmp_dir, dvc): remote: testremote md5: acbd18db4cc2f85cedef654fccc4a4d8 size: 3 + hash: md5 meta: some metadata """ ) @@ -975,6 +976,7 @@ def test_add_updates_to_cloud_versioning_dir(tmp_dir, dvc): "outs": [ { "path": "data", + "hash": "md5", "files": [ { "size": 3, @@ -1007,6 +1009,7 @@ def test_add_updates_to_cloud_versioning_dir(tmp_dir, dvc): "outs": [ { "path": "data", + "hash": "md5", "files": [ { "size": 4,