From fe1f151ae1b19faeb698361114c48bc586344984 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 20 Nov 2017 06:10:42 +0100 Subject: [PATCH 1/2] cache: Return error during default dir detection --- internal/cache/cache.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cache/cache.go b/internal/cache/cache.go index db8f1ae02..aacb8db65 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -86,6 +86,9 @@ func writeCachedirTag(dir string) error { func New(id string, basedir string) (c *Cache, err error) { if basedir == "" { basedir, err = DefaultDir() + if err != nil { + return nil, err + } } err = mkdirCacheDir(basedir) From ea593fca1b1aefe86aa432f59b82ceda93008844 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 20 Nov 2017 06:11:18 +0100 Subject: [PATCH 2/2] cache: Correctly return dir for Windows/darwin --- internal/cache/dir.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/cache/dir.go b/internal/cache/dir.go index 55ec8ea9a..398e806ca 100644 --- a/internal/cache/dir.go +++ b/internal/cache/dir.go @@ -56,10 +56,16 @@ func DefaultDir() (cachedir string, err error) { cachedir, err = darwinCacheDir() case "windows": cachedir, err = windowsCacheDir() + default: + // Default to XDG for Linux and any other OSes. + cachedir, err = xdgCacheDir() } - // Default to XDG for Linux and any other OSes. - return xdgCacheDir() + if err != nil { + return "", err + } + + return cachedir, nil } func mkdirCacheDir(cachedir string) error {