Skip to content

Commit

Permalink
index: build: use detail=True if not localfs
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Dec 13, 2023
1 parent 7ca63e6 commit 5777edd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/dvc_data/index/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from itertools import chain
from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Tuple

from dvc_objects.fs.local import LocalFileSystem

from dvc_data.hashfile.hash import DEFAULT_ALGORITHM, hash_file
from dvc_data.hashfile.meta import Meta

Expand Down Expand Up @@ -46,25 +48,33 @@ def build_entries(
) -> Iterable[DataIndexEntry]:
# NOTE: can't use detail=True with walk, because that will make it error
# out on broken symlinks.
detail = not isinstance(fs, LocalFileSystem)
if ignore:
walk_iter = ignore.walk(fs, path)
walk_iter = ignore.walk(fs, path, detail=detail)
else:
walk_iter = fs.walk(path)
walk_iter = fs.walk(path, detail=detail)

for root, dirs, files in walk_iter:
if root == path:
root_key: Tuple[str, ...] = ()
else:
root_key = fs.path.relparts(root, path)

for name in chain(dirs, files):
entries: Iterable[Tuple[str, Optional[Dict]]]
if detail:
entries = chain(dirs.items(), files.items())
else:
entries = ((name, None) for name in chain(dirs, files))

for name, info in entries:
try:
entry = build_entry(
fs.path.join(root, name),
fs,
compute_hash=compute_hash,
state=state,
hash_name=hash_name,
info=info,
)
except FileNotFoundError:
entry = DataIndexEntry()
Expand Down

0 comments on commit 5777edd

Please sign in to comment.