Skip to content

Commit

Permalink
DirFS: Handle paths with no leading / (fsspec#1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
metadaddy committed Jun 27, 2024
1 parent 262f664 commit d187403
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fsspec/implementations/dirfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ def _relpath(self, path):
return path
if path == self.path:
return ""
prefix = self.path + self.fs.sep
# S3FileSystem returns paths that do not start with a '/', so we
# need to remove the leading '/' from self.path if there is one there
# but not on the incoming path
if not path.startswith(self.fs.sep) and self.path.startswith(self.fs.sep):
prefix = self.path[1:] + self.fs.sep
else:
prefix = self.path + self.fs.sep
print(f'### path={path}, prefix={prefix}')
assert path.startswith(prefix)
return path[len(prefix) :]
return [self._relpath(_path) for _path in path]
Expand Down

0 comments on commit d187403

Please sign in to comment.