Repository navigation
Preserve leading slashes in S3 directory listings - #1097
Open
samhoon000 wants to merge 1 commit into
Open
samhoon000 wants to merge 1 commit into
samhoon000 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
S3FileSystem.ls()drops leading slashes from the object-key portion of the list prefix. Listings3://bucket//test_path/can return entries unders3://bucket/test_path/or raiseFileNotFoundError.Build the prefix from the key returned by
split_path(), preserving the slashes that belong to the key. The regression tests store objects under both prefixes and check that listing each prefix returns its own directory. They cover keys beginning with one or two slashes.Validation
pytest -q s3fs/tests/test_s3fs.py -k 'leading_slashes_in_key or leading_forward_slash or test_lsdir'on Windows with Moto. All four passed after the fix. Both new cases failed before the fix because the leading-slash path returned the regular path's directory.pytest -q s3fs/tests/test_s3fs.py -k 'listing or test_ls or leading_forward_slash', passed all 10 cases.pytest -q s3fs: 358 passed, 2 skipped, 4 xfailed, 50 failed, and 89 setup errors on Windows. The same 47 derived-suite failures and 89 setup errors occurred on the unchanged base commit. The three remaining core failures also reproduced on the base commit, including two Windows path cases and an async test without its pytest plugin.pre-commit run --files s3fs/core.py s3fs/tests/test_s3fs.pyandgit diff --checkpassed.Fixes #770.