Updates the XDG path creation to create needed dirs and panic on failure #113
No reviewers
Labels
No Label
blocked
bug
build
documentation
duplicate
enhancement
finger
gemini
gopher
help wanted
http
in progress
invalid
local
needs-info
non-code
non-functional
non-urgent
question
release
rendering
suggestion
telnet
terminal
urgent
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sloum/bombadillo#113
Loading…
Reference in New Issue
No description provided.
Delete Branch "create-config-dir"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It was reported that when there is no
XDG_CONFIG_HOME
and no~/.config
directory exists that Bombadillo silently dies. To fix this jboverf suggested, very correctly, that we useos.MkdirAll
to make sure all elements of the path get built out. This has been done. If the attempt to make the path elements fails then the program will panic with a message explaining what it was trying to do.This was reported as being an issue present on OpenBSD (and likely NetBSD), but I think it likely is present on all systems (which is a big bummer). I am hopeful that a 2.1.0 release will come about before the end of the month with a few such updates that do usability and stability fixes to the 2.0.0 build.
This being merged in should close out issue #112
This issue will occur for any directory specified in "configlocation" that does not exist.
What are your thoughts about doing this as part of
saveConfig()
instead?Also, is this something that we could add error messages for?
@asdf You are right. This could affect any path put into
defaults.go
. As such, I have moved the logic toloadConfig
. This only gets called once at the beginning of a session, which would be the proper place to error out if we are going to, rather thansaveConfig
which gets called a lot (and not right at the beginning of a session). I think this makes sense. It also showed me a place where we were not joining paths correctly, so that got updated as well. I am now passing the error in accordance with howloadConfig
has been set up.Another non-filepath join...I'm really surprised at how hard they are to find.
I found an issue where this implementation will produce a directory named
configlocation + bombadillo.ini
. I've made a small change to theMkdirAll
using onlyconfiglocation
.I also made a change to the error message. I can't tell if it's useful yet, as explained below...
There are other situations that will still result in this same situation:
configlocation
is emptyconfiglocation
already exists as a fileconfiglocation
can't be created due to permissionsI don't think any of these should be handled differently, but some error should be returned. It seems that when initialisation fails, the program panics and (maybe?) is meant to return these messages, but they don't appear.
I think this should probably go in as it is, and I'll raise another issue to investigate where the error messages are going.
Oh! Thanks for catching that I had joined when I didnt need to for the
MkdirAll
. I am surprised I didnt catch that. I definitely agree that messaging should be provided to the user. If possible trying out a situation that forces each of the three issues to see what error gets generated would be good. Then we can make sure the messaging makes it clear what is happening, where, and how it can be resolved.