Skip to content

fix: download directories with http fs #1893

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frostming
Copy link

Signed-off-by: Frost Ming [email protected]

This PR includes two fixes:

  • Skip directories when getting file from remote http to local
  • Unquote file names when creating local files

Copy link
Member

@martindurant martindurant left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I have a comment about where best to insert it.

On the issue of unquote, do you have an example of the kind of thing you were seeing? This is essentially an HTTP href-> path translation? If yes, maybe it should be done at listing time?

@@ -253,6 +254,9 @@ async def _get_file(
kw.update(kwargs)
logger.debug(rpath)
session = await self.set_session()
if await self._isdir(rpath):
Copy link
Member

Choose a reason for hiding this comment

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

This will result in essentially every file getting downloaded twice, once to check the directory. This information should already be available in _get(), so we can skip there rather than here. It doesn't really make sense to call _get_file() on a path that is not considered a file.

Copy link
Author

@frostming frostming Jul 23, 2025

Choose a reason for hiding this comment

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

I tried to exclude dirs from the return result of self._expand_path but it will always add the root to the result, if we do not check is_dir in get_file, it will also fail there.

I think I might need to change more things at this point, which is a bit risky for a first contribution. What is your suggestion?

@frostming
Copy link
Author

On the issue of unquote, do you have an example of the kind of thing you were seeing? This is essentially an HTTP href-> path translation? If yes, maybe it should be done at listing time?

I don't think so. ls()/find() might return absolute URLs, and URL encoding is reasonable here. It only needs to be unquoted when downloading to local paths(get)

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