Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e254581

Browse files
committed
fix: Update default cache directory
Fixes #2534.
1 parent 189c562 commit e254581

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/server.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,16 @@ func Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, error))
785785
"Serve pprof metrics on the address defined by `pprof-address`.")
786786
cliflag.StringVarP(root.Flags(), &pprofAddress, "pprof-address", "", "CODER_PPROF_ADDRESS", "127.0.0.1:6060",
787787
"The bind address to serve pprof.")
788-
defaultCacheDir := filepath.Join(os.TempDir(), "coder-cache")
788+
789+
defaultCacheDir, err := os.UserCacheDir()
790+
if err != nil {
791+
defaultCacheDir = os.TempDir()
792+
}
789793
if dir := os.Getenv("CACHE_DIRECTORY"); dir != "" {
790794
// For compatibility with systemd.
791795
defaultCacheDir = dir
792796
}
797+
defaultCacheDir = filepath.Join(defaultCacheDir, "coder")
793798
cliflag.StringVarP(root.Flags(), &cacheDir, "cache-dir", "", "CODER_CACHE_DIRECTORY", defaultCacheDir,
794799
"The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.")
795800
cliflag.BoolVarP(root.Flags(), &inMemoryDatabase, "in-memory", "", "CODER_INMEMORY", false,

0 commit comments

Comments
 (0)