Skip to content

Commit

Permalink
add tests from fsspec
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Aug 27, 2024
1 parent 267a9f4 commit c75471b
Show file tree
Hide file tree
Showing 2 changed files with 812 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dvc/fs/dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ def _get( # noqa: C901
lpath = self.join(lpath, os.path.basename(rpath))

if self.isfile(rpath):
os.makedirs(os.path.dirname(lpath), exist_ok=True)
with callback.branched(rpath, lpath) as child:
self.get_file(rpath, lpath, callback=child, **kwargs)
return [(rpath, lpath)]
Expand All @@ -544,7 +543,8 @@ def _get( # noqa: C901
if parts in ((os.curdir,), ("",)):
parts = ()
dest_root = os.path.join(lpath, *parts)
_dirs.extend(f"{dest_root}{os.path.sep}{d}" for d in dirs)
if not maxdepth or len(parts) < maxdepth - 1:
_dirs.extend(f"{dest_root}{os.path.sep}{d}" for d in dirs)

key = self._get_key_from_relative(root)
_, dvc_fs, _ = self._get_subrepo_info(key)
Expand Down Expand Up @@ -577,6 +577,11 @@ def get_file(self, rpath, lpath, **kwargs):
key = self._get_key_from_relative(rpath)
fs_path = self._from_key(key)

dirpath = os.path.dirname(lpath)
if dirpath:
# makedirs raises error if the string is empty
os.makedirs(dirpath, exist_ok=True)

try:
return self.repo.fs.get_file(fs_path, lpath, **kwargs)
except FileNotFoundError:
Expand Down
Loading

0 comments on commit c75471b

Please sign in to comment.