Skip to content

Commit 1006fcf

Browse files
display correct XDG directories in error message
1 parent 5e417b3 commit 1006fcf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

filesearch/filesearch.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
)
1313

1414
var (
15+
XDGAppName = "resticprofile"
16+
1517
// configurationExtensions list the possible extensions for the config file
1618
configurationExtensions = []string{
1719
"conf",
@@ -82,7 +84,10 @@ func FindConfigurationFile(configFile string) (string, error) {
8284
return found, nil
8385
}
8486
// compile a list of search locations
85-
locations := append([]string{xdg.ConfigHome}, xdg.ConfigDirs...)
87+
locations := []string{filepath.Join(xdg.ConfigHome, XDGAppName)}
88+
for _, configDir := range xdg.ConfigDirs {
89+
locations = append(locations, filepath.Join(configDir, XDGAppName))
90+
}
8691
locations = append(locations, getDefaultConfigurationLocations()...)
8792
if home, err := os.UserHomeDir(); err == nil {
8893
locations = append(locations, home)
@@ -97,7 +102,7 @@ func findConfigurationFileWithExtension(configFile string) string {
97102
}
98103

99104
// 2. Next we try xdg as the "standard" for user configuration locations
100-
xdgFilename, err := xdg.SearchConfigFile(filepath.Join("resticprofile", configFile))
105+
xdgFilename, err := xdg.SearchConfigFile(filepath.Join(XDGAppName, configFile))
101106
if err == nil {
102107
if fileExists(xdgFilename) {
103108
return xdgFilename

0 commit comments

Comments
 (0)