-
Notifications
You must be signed in to change notification settings - Fork 366
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
spec: get_file: don't pollute with files and fds #1191
Conversation
Currently if anything happens in fs.open we will leave an empty file in user's workspace and also won't close the file descriptor. Both things are pretty bad.
if isfilelike(lpath): | ||
outfile = lpath | ||
else: | ||
if self.isdir(rpath): | ||
os.makedirs(lpath, exist_ok=True) | ||
return None | ||
elif self.isdir(rpath): | ||
os.makedirs(lpath, exist_ok=True) | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't seem mutually exclusive, but I've preserved logic that was here before. Not sure what outfile
argument is even used for, but it is strange that makedirs
-behaviour (which is also odd by itself) doesn't affect it.
EDIT: nevermind, indeed they are mutually exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also calling isdir
on every file is very wasteful. Ideally, we should get rid of this at some point in the future, as it seems to be a misplaced piece of logic from fs.get
rather than something that is intentional here. From user's perspective I would expect IsADirectoryError
here.
While waiting for fsspec/filesystem_spec#1191
While waiting for fsspec/filesystem_spec#1191
While waiting for fsspec/filesystem_spec#1191
* spec: get_file: don't pollute with files and fds Currently if anything happens in fs.open we will leave an empty file in user's workspace and also won't close the file descriptor. Both things are pretty bad. * http: _get_file: don't leak file descriptor
Currently if anything happens in fs.open we will leave an empty file in user's workspace and also won't close the file descriptor. Both things are pretty bad.