From 99daf5d113faccc70f8233ef05363257d3dddf5c Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Wed, 17 May 2023 12:03:06 +0545 Subject: [PATCH] add: fail loudly if there's no dir cache (#9466) --- dvc/output.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index a11a36960..2bf387f82 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -1222,10 +1222,12 @@ class Output: assert isinstance(self.fs.path, Path) rel_key = tuple(self.fs.path.parts(self.fs.path.relpath(path, self.fs_path))) - if not self.hash_info: - tree = Tree() + if self.hash_info: + tree = self.get_dir_cache() + if tree is None: + raise DvcException(f"could not read {self.hash_info.value!r}") else: - tree = self.get_dir_cache() or Tree() + tree = Tree() trie = tree.as_trie() assert isinstance(trie, Trie) @@ -1257,10 +1259,12 @@ class Output: append_only = True rel_key = tuple(self.fs.path.parts(self.fs.path.relpath(path, self.fs_path))) - if not self.hash_info: - tree = Tree() + if self.hash_info: + tree = self.get_dir_cache() + if tree is None: + raise DvcException(f"could not read {self.hash_info.value!r}") else: - tree = self.get_dir_cache() or Tree() + tree = Tree() trie = tree.as_trie() assert isinstance(trie, Trie)