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

download_to does not create non-existent parent directories #57

Open
pjbull opened this issue Aug 30, 2020 · 0 comments
Open

download_to does not create non-existent parent directories #57

pjbull opened this issue Aug 30, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@pjbull
Copy link
Member

pjbull commented Aug 30, 2020

A call like cloud_path.download_to("a/b/c/d.txt") will possibly (though not certainly depending on backend, see #56) error if local directories a or b or c does not exist.

This is similar to other pathlib functions, but annoying for developers. Tracking disucssion of the preferred approach in this issue.


Discussion for context:

That is doubly true. First, that pathlib never creates dirs for you, and second that it is inconvenient annoying. In a bunch of our projects we've got a repeated path.parent.mkdir(exist_ok=True, parents=True) before each path write.

I don't feel strongly either way. I didn't track down a reason for pathlib not creating dirs in some cursory searching of the Python bug tracker / mailing list, and I would be curious to see discussion why file creation methods (like write_text for example) wouldn't create the full path. I guess it's not explicitly saying to create a directory, but Path("asdf/asdf/asdf.txt").write_text("asdf") does seem pretty explicit...

In the absence of a reason not to, I'm inclined to create directories since that feels more useful and more like the API I would want to use in my development experience, but happy to punt the discussion to an issue as well.

I guess my inclination is to punt for now. Given that the precedent is to not create directories for you automatically, not just for pathlib, but also for shells like bash, I think it makes sense to standardize at first on that. If we decide otherwise, I think we should make a concerted effort to do that consistently everywhere in cloudpathlib, and also test for it everywhere.

Originally posted by @jayqi in #52 (comment)

@pjbull pjbull added the enhancement New feature or request label Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant