Skip to content

Commit

Permalink
Update xdg.SearchRuntimeFile to also look in temporary directory
Browse files Browse the repository at this point in the history
  • Loading branch information
adrg committed Oct 31, 2024
1 parent 2335a68 commit 800775a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base_dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ func (bd baseDirectories) searchCacheFile(relPath string) (string, error) {
}

func (bd baseDirectories) searchRuntimeFile(relPath string) (string, error) {
return pathutil.Search(relPath, []string{bd.runtime})
return pathutil.Search(relPath, pathutil.Unique([]string{bd.runtime, os.TempDir()}))
}
7 changes: 5 additions & 2 deletions xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ func SearchCacheFile(relPath string) (string, error) {

// SearchRuntimeFile searches for the specified file in the runtime search path.
// The relPath parameter must contain the name of the runtime file, and
// optionally, a set of parent directories (e.g. appname/app.pid). If the
// file cannot be found, an error specifying the searched path is returned.
// optionally, a set of parent directories (e.g. appname/app.pid). The runtime
// file is also searched in the operating system's temporary directory in order
// to cover cases in which the runtime base directory does not exist or is not
// accessible. If the file cannot be found, an error specifying the searched
// path is returned.
func SearchRuntimeFile(relPath string) (string, error) {
return baseDirs.searchRuntimeFile(relPath)
}

0 comments on commit 800775a

Please sign in to comment.