Skip to content

Commit

Permalink
ls: Use fs.walk(..., detail=True) instead of separate call to fs.info()
Browse files Browse the repository at this point in the history
  • Loading branch information
rlamy committed Aug 22, 2022
1 parent 69d22c2 commit c4b8b19
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dvc/repo/ls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from itertools import chain
from typing import TYPE_CHECKING, Optional

from dvc.exceptions import PathMissingError
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c4b8b19

Please sign in to comment.