diff --git a/fsspec/spec.py b/fsspec/spec.py index a58331f8c..769b20a15 100644 --- a/fsspec/spec.py +++ b/fsspec/spec.py @@ -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, @@ -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: @@ -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"""