Skip to content

Commit f2b7b00

Browse files
authored
dvcfilesystem.get: prefer downloading from repo.fs before dvc.fs (#10543)
1 parent 4f3fb15 commit f2b7b00

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dvc/fs/dvc.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -558,25 +558,29 @@ def _get( # noqa: C901
558558
for d in _dirs:
559559
os.mkdir(d)
560560

561+
repo_fs = self.repo.fs
562+
561563
def _get_file(arg):
562564
dvc_fs, src, dest, info = arg
563565
dvc_info = info.get("dvc_info")
564-
if dvc_info and dvc_fs:
566+
fs_info = info.get("fs_info")
567+
if dvc_fs and dvc_info and not fs_info:
565568
dvc_path = dvc_info["name"]
566569
dvc_fs.get_file(
567570
dvc_path, dest, callback=callback, info=dvc_info, **kwargs
568571
)
569572
else:
570-
self.get_file(src, dest, callback=callback, **kwargs)
573+
fs_path = fs_info["name"]
574+
repo_fs.get_file(fs_path, dest, callback=callback, **kwargs)
571575
return src, dest, info
572576

573577
with ThreadPoolExecutor(max_workers=batch_size) as executor:
574578
return list(executor.imap_unordered(_get_file, _files))
575579

576580
def get_file(self, rpath, lpath, **kwargs):
581+
dvc_info = kwargs.pop("info", {}).pop("dvc_info", None)
577582
key = self._get_key_from_relative(rpath)
578583
fs_path = self._from_key(key)
579-
580584
dirpath = os.path.dirname(lpath)
581585
if dirpath:
582586
# makedirs raises error if the string is empty
@@ -590,7 +594,7 @@ def get_file(self, rpath, lpath, **kwargs):
590594
raise
591595

592596
dvc_path = _get_dvc_path(dvc_fs, subkey)
593-
return dvc_fs.get_file(dvc_path, lpath, **kwargs)
597+
return dvc_fs.get_file(dvc_path, lpath, info=dvc_info, **kwargs)
594598

595599
def du(self, path, total=True, maxdepth=None, withdirs=False, **kwargs):
596600
if maxdepth is not None:

0 commit comments

Comments
 (0)