Skip to content

Normalize path prefixes in shared archive ls - #2197

Merged
martindurant merged 2 commits into
fsspec:masterfrom
rioyu123:codex/archive-listing-path-normalization
Sep 28, 2026
Merged

martindurant merged 2 commits into
fsspec:masterfrom
rioyu123:codex/archive-listing-path-normalization

Conversation

@rioyu123

Copy link
Copy Markdown
Contributor

With a ZIP archive, fs.ls("/deeply") returns ["deeply"] instead of the directory's contents, and protocol-prefixed paths such as fs.ls("zip://") or fs.ls("zip://deeply") return an empty list. The shared AbstractArchiveFileSystem.ls compared the raw input against archive-relative entries, while info and open already strip the protocol and leading slashes.

This passes the path through _strip_protocol at the start of ls. ZipFileSystem and LibArchiveFileSystem use this shared method; TarFileSystem already normalizes in its own ls override.

A new shared archive test checks that /, <protocol>:// and <protocol>:/// prefixes give the same result as the plain path for the root, nested directories and a file, in both detail modes, and that missing paths still raise FileNotFoundError.

Testing: without the fix, the new test fails for all six ZIP cases and passes for the tar variants. With the fix, test_archive.py, test_zip.py and test_tar.py pass (220 passed, 27 skipped). libarchive isn't installed locally, so its cases were skipped. Ruff 0.14.3 and git diff --check pass on the changed files.

@martindurant
martindurant merged commit 9c00fb0 into fsspec:master Sep 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants