-
Notifications
You must be signed in to change notification settings - Fork 20
CFE-4520: Fixed missing "packages" dir with install --package on fresh cf-remote install #135
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
Conversation
jakub-nt
left a comment
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.
Maybe it would be slightly better to perform the path existence check in download_package instead of _download_urls?
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.
Looking at this commit, it's not clear what difference your change makes mkdir vs os.mkdir look like they're supposed to do the same thing, so I'd expect some further explanation in the commit message.
Did you reproduce the issue in the ticket and confirm that your change fixes the issue? Your commit message could include the error message from before, and the reason why os.mkdir and mkdir are different.
The code which was already there is questionable to begin with; it introduces an unnecessary race condition between checking if the dir exists and creating it (someone could create it between those 2 steps). It's also not very explicit about whether parent dirs should be created, or what should happen if there is a file there instead of a directory.
Instead of:
if not os.path.isdir(urls_dir):
mkdir(urls_dir)I would do something like:
# os.makedirs also creates parents
os.makedirs(urls_dir, exist_ok=True)or:
try:
# os.makedirs also creates parents
os.makedirs(urls_dir, exist_ok=True)
except:
# Handle exceptions here
assert(os.path.isdir(urls_dir))(That logic could probably be worked into the mkdir() util function as well.)
|
After After change: From my understanding, the origin of the bug is that The difference between I found it strange that we created a function for mkdir if it introduces a race condition. I used because I thought it would make sense to reuse something we already made. Code for mkdir: def mkdir(path):
if not os.path.exists(path):
log.info("Creating directory: '{}'".format(path))
os.makedirs(path)
else:
log.debug("Directory already exists: '{}'".format(path)) |
…e install Ticket: CFE-4520 Signed-off-by: Victor Moene <[email protected]>
No description provided.