fsspec / fsspec/filesystem_spec

LocalFileSystem glob removes trailing slash

Open
#1,322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

According to the documentation of AbstractFileSystem, glob should act as ls when the path ends with /.

But when using the LocalFileSystem method, the trailing slash is removed when _strip_protocol is called.

Example:

from fsspec.implementations.local import LocalFileSystem

lfs = LocalFileSystem(auto_mkdir=True)

lfs.touch(path="/tmp/data/a.txt")
lfs.touch(path="/tmp/data/b/a.txt")
print(lfs.glob(path="/tmp/data/"))

Output:

['/tmp/data']

Expected output:

['/tmp/data/a.txt', '/tmp/data/b']

A solution would be to completely remove the glob method in the LocalFileSystem class and let the AbstractFileSystem method do the _strip_protocol call (see here)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the LocalFileSystem glob implementation in fsspec/implementations/local.py and compare its path handling with AbstractFileSystem.glob in fsspec/spec.py. Reproduce the trailing-slash example, then verify that glob('/tmp/data/') returns the directory contents shown in the expected output without changing other glob behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.