From e25458107f1115a1ae0e5d6e7ac212853279d64b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 23 Sep 2022 18:50:05 +0000 Subject: [PATCH] fix: Update default cache directory Fixes #2534. --- cli/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/server.go b/cli/server.go index 763e3438b3278..5c320a4e0ceaf 100644 --- a/cli/server.go +++ b/cli/server.go @@ -785,11 +785,16 @@ func Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, error)) "Serve pprof metrics on the address defined by `pprof-address`.") cliflag.StringVarP(root.Flags(), &pprofAddress, "pprof-address", "", "CODER_PPROF_ADDRESS", "127.0.0.1:6060", "The bind address to serve pprof.") - defaultCacheDir := filepath.Join(os.TempDir(), "coder-cache") + + defaultCacheDir, err := os.UserCacheDir() + if err != nil { + defaultCacheDir = os.TempDir() + } if dir := os.Getenv("CACHE_DIRECTORY"); dir != "" { // For compatibility with systemd. defaultCacheDir = dir } + defaultCacheDir = filepath.Join(defaultCacheDir, "coder") cliflag.StringVarP(root.Flags(), &cacheDir, "cache-dir", "", "CODER_CACHE_DIRECTORY", defaultCacheDir, "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.") cliflag.BoolVarP(root.Flags(), &inMemoryDatabase, "in-memory", "", "CODER_INMEMORY", false,