diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index efbc7fd62..ad1a9bb5c 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -1,5 +1,4 @@ import os -from itertools import chain from typing import TYPE_CHECKING, Optional from dvc.exceptions import PathMissingError @@ -66,15 +65,16 @@ def _ls( infos = {} for root, dirs, files in fs.walk( - fs_path, dvcfiles=True, dvc_only=dvc_only + fs_path, dvcfiles=True, dvc_only=dvc_only, detail=True ): - entries = chain(files, dirs) if not recursive else files + if not recursive: + files.update(dirs) - for entry in entries: - entry_fs_path = fs.path.join(root, entry) + for name, entry in files.items(): + entry_fs_path = fs.path.join(root, name) relparts = fs.path.relparts(entry_fs_path, fs_path) name = os.path.join(*relparts) - infos[name] = fs.info(entry_fs_path) + infos[name] = entry if not recursive: break