Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mixup of paths in put function #1179

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def put(self, lpath, rpath, recursive=False, callback=_DEFAULT_CALLBACK, **kwarg
if isinstance(lpath, str):
lpath = make_path_posix(lpath)
fs = LocalFileSystem()
lpaths = fs.expand_path(lpath, recursive=recursive)
lpaths = fs.expand_path(lpath, recursive=recursive, sort=False)
isdir = isinstance(rpath, str) and self.isdir(rpath)
rpaths = other_paths(
lpaths,
Expand Down Expand Up @@ -992,7 +992,7 @@ def copy(self, path1, path2, recursive=False, on_error=None, **kwargs):
if on_error == "raise":
raise

def expand_path(self, path, recursive=False, maxdepth=None):
def expand_path(self, path, recursive=False, maxdepth=None, sort=True):
"""Turn one or more globs or directories into a list of all matching paths
to files or directories."""
if maxdepth is not None and maxdepth < 1:
Expand Down Expand Up @@ -1026,7 +1026,10 @@ def expand_path(self, path, recursive=False, maxdepth=None):
maxdepth = maxdepth if not maxdepth else maxdepth - 1
if not out:
raise FileNotFoundError(path)
return list(sorted(out))
if sort:
return list(sorted(out))
else:
return list(out)

def mv(self, path1, path2, recursive=False, maxdepth=None, **kwargs):
"""Move file(s) from one location to another"""
Expand Down