mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
index: build_data_index: handle empty dirs (#8959)
Fixes https://github.com/iterative/dvc/issues/8958
This commit is contained in:
+1
-2
@@ -526,9 +526,9 @@ def build_data_index(
|
||||
out_entry = DataIndexEntry(path=out_path, fs=fs)
|
||||
|
||||
out_entry.key = key
|
||||
data.add(out_entry)
|
||||
|
||||
if not out_entry.meta or not out_entry.meta.isdir:
|
||||
data.add(out_entry)
|
||||
continue
|
||||
|
||||
for entry in build_entries(
|
||||
@@ -546,7 +546,6 @@ def build_data_index(
|
||||
tree_meta, tree = build_tree(data, key)
|
||||
out_entry.meta = tree_meta
|
||||
out_entry.hash_info = tree.hash_info
|
||||
|
||||
out_entry.loaded = True
|
||||
data.add(out_entry)
|
||||
|
||||
|
||||
@@ -442,3 +442,18 @@ def test_root_from_file_to_dir(M, tmp_dir, dvc, scm):
|
||||
},
|
||||
"git": M.dict(),
|
||||
}
|
||||
|
||||
|
||||
def test_empty_dir(tmp_dir, scm, dvc, M):
|
||||
# regression testing for https://github.com/iterative/dvc/issues/8958
|
||||
tmp_dir.dvc_gen({"data": {"foo": "foo"}})
|
||||
remove("data")
|
||||
|
||||
(tmp_dir / "data").mkdir()
|
||||
|
||||
assert dvc.data_status() == {
|
||||
**EMPTY_STATUS,
|
||||
"committed": {"added": [join("data", "")]},
|
||||
"uncommitted": {"modified": [join("data", "")]},
|
||||
"git": M.dict(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user