From 8e99fd0091a89e3efbe0519b326f99af240311b6 Mon Sep 17 00:00:00 2001 From: Ronan Lamy Date: Mon, 22 Aug 2022 13:03:22 +0100 Subject: [PATCH] ls: Use fs.walk(..., detail=True) instead of separate call to fs.info() --- dvc/repo/ls.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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