Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _scandir bug #3

Closed
wants to merge 1 commit into from
Closed

Fix _scandir bug #3

wants to merge 1 commit into from

Conversation

trendelkampschroer
Copy link
Contributor

@trendelkampschroer trendelkampschroer commented Nov 12, 2018

This PR fixes a bug in the _scandir implementation. As a result of this bug _scandir did not list files at the root_path of the file-system, when the root_path of the file-system was identical to the top-level of the GCS bucket.

@@ -186,14 +186,12 @@ def _scandir(self, path: str, return_info: bool = False, namespaces: List[str] =
dir_key = self._path_to_dir_key(_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should look into the self._path_to_dir_key(_path) why it does not find the right dir_key and prefix. The change here feels kind of random (e.g. have to change dir_key = "/" but dfir_key = "/foo/ is fine

prefix_len = len(prefix)
# In case we want to list the bucket, dir_key needs to be the empty string
dir_key = ""
prefix_len = len(dir_key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really understand what the problem was and why it is fixed now.

As far as I can see you only mutated dir_key instead of introducing a new variable prefix here (which I found to be more explicit, as the dir_key is actually correct, it just does not work with list_blobs).

Copy link
Contributor Author

@trendelkampschroer trendelkampschroer Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was twofold:
i) prefix was overwritten by a loop variable created when iterating over prefixes
ii) some calls to list_blobs used dir_key instead of prefix (which was correct as long as dir_key != "/")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be beneficial, if the behaviour of _path_to_key(root) and _path_to_dir_key(root) would be clearly defined if the root_path of the file system is the root of the bucket and root is any valid pyfilesystem specifier for the root of a filesystem.

@MaxBenChrist
Copy link

This is obsolete due to #5

@trendelkampschroer
Copy link
Contributor Author

Closed by #5

@birnbaum birnbaum deleted the fix_scandir branch November 16, 2018 11:13
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.

4 participants