octogit
octogit copied to clipboard
stop crashing if only config file is missing
how do I produce the bug you are trying to fix here?
Delete the config file, but not the directory that contained it.
Excellent what would make this better is to include the default creation of the config file, instead of it silently failing, there is a format to the standard config file it isn't just about creating a file in that location.
@myusuf3 looking at the diff, it appears the file is created if it doesn't exist, and it's also setup with the default section, username, and password. What do you think is missing from @viraptor's commit?
This change looks good to me - the os.makedirs call is just to ensure the directory exists, it's allowed to fail silently (the config file is created regardless)
Pedantically I'd put a else: pass to make that clear, like:
try:
os.makedirs(os.path.dirname(CONFIG_FILE))
except OSError as e:
if e.errno != os.errno.EEXIST:
raise
else:
pass # Directory already exists
..but it should be perfectly clear without it
@viraptor if suggestions by @dbr i will gladly merge in the change here. You are totally correct guys. I was smoking dope.