Skip to content

Ensure directories for storing files actually exist #227

@stejcon

Description

@stejcon

In my config, I had written:
"historyFile": "$XDG_STATE_HOME/clipse/clipboard_history.json",

I was expecting the program to create the directory clipse and then place the clipboard_history file in there. What I actually got was this error:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x24 pc=0x56267c590bd4] goroutine 1 [running]: log.(*Logger).output(0xc00001e140?, 0x49?, 0xc0001b3d40?, 0x56267c55379a?)	log/log.go:203 +0x34 log.(*Logger).Printf(...)	log/log.go:268 github.com/savedra1/clipse/utils.LogERROR({0xc00001e140?, 0x13?})	github.com/savedra1/clipse/utils/logger.go:19 +0xa5 github.com/savedra1/clipse/config.initHistoryFile()	github.com/savedra1/clipse/config/history.go:43 +0x159 github.com/savedra1/clipse/config.Init()	github.com/savedra1/clipse/config/config.go:60 +0x17e main.main()	github.com/savedra1/clipse/main.go:38 +0x65 

While not tested, this likely applies to the ClipseConfig.ThemeFilePath creation as well. The fix for this would probably be using os.MkdirAll before actually creating any files needed in the config. Not opening a PR myself as this issue likely occurs in multiple places that would need to be checked.

Output of clipse -v:
clipse v1.1.0

Please let me know if this is already fixed in an unreleased version, although it doesn't seem to be from a quick glance at the commits since the release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions