Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: search geodata at same dir with config first #84

Merged
merged 2 commits into from
May 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions common/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func (c *LocationFinder) GetLocationAsset(log *logrus.Logger, filename string) (
// Search dirs.
var searchDirs []string
folder := "dae"
location := os.Getenv("DAE_LOCATION_ASSET")
// check if DAE_LOCATION_ASSET is set
location := os.Getenv("DAE_LOCATION_ASSET")
if location != "" {
// add DAE_LOCATION_ASSET to search path
searchDirs = []string{
location,
}
searchDirs = append(searchDirs, location)
// add /etc/dae to search path
searchDirs = append(searchDirs, c.externDirs...)
// additional paths for non windows platforms
if runtime.GOOS != "windows" {
searchDirs = append(
Expand All @@ -87,15 +87,16 @@ func (c *LocationFinder) GetLocationAsset(log *logrus.Logger, filename string) (
}
searchDirs = append(searchDirs, c.externDirs...)
} else {
// add /etc/dae to search path
searchDirs = append(searchDirs, c.externDirs...)
if runtime.GOOS != "windows" {
// Search XDG data directories on non windows platform
searchDirs = append([]string{xdg.DataHome}, xdg.DataDirs...)
searchDirs = append(searchDirs, xdg.DataHome)
searchDirs = append(searchDirs, xdg.DataDirs...)
for i := range searchDirs {
searchDirs[i] = filepath.Join(searchDirs[i], folder)
}
searchDirs = append(searchDirs, c.externDirs...)
} else {
searchDirs = append([]string{}, c.externDirs...)
// fallback to the old behavior of using only current dir on Windows
pwd := "./"
if absPath, e := filepath.Abs(pwd); e == nil {
Expand Down