Skip to content

Commit eb200db

Browse files
authored
Merge pull request #2909 from iterative/efiop-patch-1
remote: base: download: don't walk dir twice
2 parents 9b6644a + cf171f7 commit eb200db

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

dvc/remote/base.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,26 +588,23 @@ def download(
588588
def _download_dir(
589589
self, from_info, to_info, name, no_progress_bar, file_mode, dir_mode
590590
):
591-
file_to_infos = (
592-
to_info / file_to_info.relative_to(from_info)
593-
for file_to_info in self.walk_files(from_info)
591+
from_infos = list(self.walk_files(from_info))
592+
to_infos = (
593+
to_info / info.relative_to(from_info) for info in from_infos
594594
)
595595

596596
with ThreadPoolExecutor(max_workers=self.JOBS) as executor:
597-
file_from_info = list(self.walk_files(from_info))
598597
download_files = partial(
599598
self._download_file,
600599
name=name,
601600
no_progress_bar=True,
602601
file_mode=file_mode,
603602
dir_mode=dir_mode,
604603
)
605-
futures = executor.map(
606-
download_files, file_from_info, file_to_infos
607-
)
604+
futures = executor.map(download_files, from_infos, to_infos)
608605
with Tqdm(
609606
futures,
610-
total=len(file_from_info),
607+
total=len(from_infos),
611608
desc="Downloading directory",
612609
unit="Files",
613610
disable=no_progress_bar,

0 commit comments

Comments
 (0)