Skip to content

Commit

Permalink
display correct XDG directories in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Jun 30, 2020
1 parent 5e417b3 commit 1006fcf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions filesearch/filesearch.go
Expand Up @@ -12,6 +12,8 @@ import (
)

var (
XDGAppName = "resticprofile"

// configurationExtensions list the possible extensions for the config file
configurationExtensions = []string{
"conf",
Expand Down Expand Up @@ -82,7 +84,10 @@ func FindConfigurationFile(configFile string) (string, error) {
return found, nil
}
// compile a list of search locations
locations := append([]string{xdg.ConfigHome}, xdg.ConfigDirs...)
locations := []string{filepath.Join(xdg.ConfigHome, XDGAppName)}
for _, configDir := range xdg.ConfigDirs {
locations = append(locations, filepath.Join(configDir, XDGAppName))
}
locations = append(locations, getDefaultConfigurationLocations()...)
if home, err := os.UserHomeDir(); err == nil {
locations = append(locations, home)
Expand All @@ -97,7 +102,7 @@ func findConfigurationFileWithExtension(configFile string) string {
}

// 2. Next we try xdg as the "standard" for user configuration locations
xdgFilename, err := xdg.SearchConfigFile(filepath.Join("resticprofile", configFile))
xdgFilename, err := xdg.SearchConfigFile(filepath.Join(XDGAppName, configFile))
if err == nil {
if fileExists(xdgFilename) {
return xdgFilename
Expand Down

0 comments on commit 1006fcf

Please sign in to comment.