Automatically create the default log directory on Linux if required#21
Closed
danielthatcher wants to merge 3 commits intowincent:masterfrom
Closed
Automatically create the default log directory on Linux if required#21danielthatcher wants to merge 3 commits intowincent:masterfrom
danielthatcher wants to merge 3 commits intowincent:masterfrom
Conversation
wincent
reviewed
Jun 15, 2020
clipper.go
Outdated
Comment on lines
+211
to
+214
| if runtime.GOOS == "linux" { | ||
| configDir := pathByExpandingTildeInPath(filepath.Dir(defaults.Logfile.value)) | ||
| os.MkdirAll(configDir, 0700) | ||
| } |
Owner
There was a problem hiding this comment.
Looks good, but I think this is the wrong place to be executing side-effectful code; this function should really just be about merging settings.
Would you be able to move this down lower, like around here right before we try to open the log file? If you do that, it will additionally take effect for log files which come in via an explicit flag or a config file, which might be a benefit too.
Author
There was a problem hiding this comment.
Should be fixed in the latest commit
Owner
|
Thanks @danielthatcher. I squashed this and applied a small tweak on top. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When installed on Linux clipper will crash on startup when run without any arguments as it can't create a new log file in the default logs directory, which doesn't exist by default:
This PR fixes that by recursively creating
~/.config/clipper/logsif it doesn't exist, and if the user hasn't requested a different log file location.