mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
fs: repo: handle directories with multiple artifacts (#6278)
Related to #5677
This commit is contained in:
+8
-8
@@ -167,10 +167,10 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
(out,) = meta.outs
|
||||
assert len(meta.outs) == 1
|
||||
if fs.exists(out.path_info):
|
||||
return False
|
||||
for out in meta.outs:
|
||||
if fs.exists(out.path_info):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def isdir(self, path): # pylint: disable=arguments-differ
|
||||
@@ -194,10 +194,10 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
(out,) = meta.outs
|
||||
assert len(meta.outs) == 1
|
||||
if fs.exists(out.path_info):
|
||||
return False
|
||||
for out in meta.outs:
|
||||
if fs.exists(out.path_info):
|
||||
return False
|
||||
|
||||
return meta.isdir
|
||||
|
||||
def isdvc(self, path, **kwargs):
|
||||
|
||||
@@ -68,7 +68,22 @@ def test_open_in_history(tmp_dir, scm, dvc):
|
||||
|
||||
|
||||
def test_isdir_isfile(tmp_dir, dvc):
|
||||
tmp_dir.gen({"datafile": "data", "datadir": {"foo": "foo", "bar": "bar"}})
|
||||
tmp_dir.gen(
|
||||
{
|
||||
"datafile": "data",
|
||||
"datadir": {
|
||||
"foo": "foo",
|
||||
"bar": "bar",
|
||||
},
|
||||
"subdir": {
|
||||
"baz": "baz",
|
||||
"data": {
|
||||
"abc": "abc",
|
||||
"xyz": "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
fs = RepoFileSystem(repo=dvc)
|
||||
assert fs.isdir("datadir")
|
||||
@@ -78,9 +93,18 @@ def test_isdir_isfile(tmp_dir, dvc):
|
||||
assert fs.isfile("datafile")
|
||||
assert not fs.isdvc("datafile")
|
||||
|
||||
dvc.add(["datadir", "datafile"])
|
||||
dvc.add(
|
||||
[
|
||||
"datadir",
|
||||
"datafile",
|
||||
os.path.join("subdir", "baz"),
|
||||
os.path.join("subdir", "data"),
|
||||
]
|
||||
)
|
||||
shutil.rmtree(tmp_dir / "datadir")
|
||||
shutil.rmtree(tmp_dir / "subdir" / "data")
|
||||
(tmp_dir / "datafile").unlink()
|
||||
(tmp_dir / "subdir" / "baz").unlink()
|
||||
|
||||
assert fs.isdir("datadir")
|
||||
assert not fs.isfile("datadir")
|
||||
@@ -89,6 +113,12 @@ def test_isdir_isfile(tmp_dir, dvc):
|
||||
assert fs.isfile("datafile")
|
||||
assert fs.isdvc("datafile")
|
||||
|
||||
assert fs.isdir("subdir")
|
||||
assert not fs.isfile("subdir")
|
||||
assert not fs.isdvc("subdir")
|
||||
assert fs.isfile(os.path.join("subdir", "baz"))
|
||||
assert fs.isdir(os.path.join("subdir", "data"))
|
||||
|
||||
|
||||
def test_exists_isdir_isfile_dirty(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen(
|
||||
|
||||
Reference in New Issue
Block a user