From a4d93d2c1c0c4b1da05cb81227198097396c2ec4 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 31 Jul 2020 22:53:42 +0300 Subject: [PATCH] tree: don't save hash twice We already do this in https://github.com/iterative/dvc/blob/00de04c82d844b3bdf5162b2c78560f1b5656488/dvc/tree/base.py#L271 for both files and directories. --- dvc/tree/base.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dvc/tree/base.py b/dvc/tree/base.py index d5df932b52..1860bafab6 100644 --- a/dvc/tree/base.py +++ b/dvc/tree/base.py @@ -280,7 +280,7 @@ def get_dir_hash(self, path_info, **kwargs): raise RemoteCacheRequiredError(path_info) dir_info = self._collect_dir(path_info, **kwargs) - return self._save_dir_info(dir_info, path_info) + return self._save_dir_info(dir_info) def hash_to_path_info(self, hash_): return self.path_info / hash_[0:2] / hash_[2:] @@ -343,7 +343,7 @@ def _collect_dir(self, path_info, **kwargs): # Sorting the list by path to ensure reproducibility return sorted(result, key=itemgetter(self.PARAM_RELPATH)) - def _save_dir_info(self, dir_info, path_info): + def _save_dir_info(self, dir_info): hash_, tmp_info = self._get_dir_info_hash(dir_info) new_info = self.cache.tree.hash_to_path_info(hash_) if self.cache.changed_cache_file(hash_): @@ -352,8 +352,6 @@ def _save_dir_info(self, dir_info, path_info): tmp_info, new_info, mode=self.cache.CACHE_MODE ) - if self.exists(path_info): - self.state.save(path_info, hash_) self.state.save(new_info, hash_) return hash_