diff --git a/base_dirs.go b/base_dirs.go index 0cdca02..65f3e3f 100644 --- a/base_dirs.go +++ b/base_dirs.go @@ -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()})) } diff --git a/xdg.go b/xdg.go index 059d695..b1f97cc 100644 --- a/xdg.go +++ b/xdg.go @@ -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) }