🧱 Chunk is a download manager for slow and unstable servers
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Moves cache dir to user's folder according to OS

+15 -7
+2
go.mod
··· 6 6 7 7 require ( 8 8 github.com/inconshreveable/mousetrap v1.1.0 // indirect 9 + github.com/mitchellh/go-homedir v1.1.0 // indirect 10 + github.com/muesli/go-app-paths v0.2.2 // indirect 9 11 github.com/spf13/pflag v1.0.9 // indirect 10 12 )
+4
go.sum
··· 1 1 github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 2 2 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 3 3 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 4 + github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 5 + github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 6 + github.com/muesli/go-app-paths v0.2.2 h1:NqG4EEZwNIhBq/pREgfBmgDmt3h1Smr1MjZiXbpZUnI= 7 + github.com/muesli/go-app-paths v0.2.2/go.mod h1:SxS3Umca63pcFcLtbjVb+J0oD7cl4ixQWoBKhGEtEho= 4 8 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 5 9 github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= 6 10 github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
+9 -7
progress.go
··· 6 6 "fmt" 7 7 "log/slog" 8 8 "os" 9 - "os/user" 10 9 "path/filepath" 11 10 "sync" 12 11 "sync/atomic" 12 + 13 + gap "github.com/muesli/go-app-paths" 13 14 ) 14 15 15 16 // DefaultChunkDir is the directory where Chunk keeps track of each chunk 16 - // downloaded of each file. It us created under the user's home directory by 17 - // default. It can be replaced by the environment variable CHUNK_DIR. 18 - const DefaultChunkDir = ".chunk" 17 + // downloaded of each file. It us created under the user's cache directory 18 + // by default. 19 + // It can be replaced by a full path in the environment variable CHUNK_DIR. 20 + const DefaultChunkDir = "chunk" 19 21 20 22 // get the chunk directory under user's home directory or using the envvar 21 23 func getChunkProgressDir(dir string) (string, error) { ··· 23 25 dir = os.Getenv("CHUNK_DIR") 24 26 } 25 27 if dir == "" { 26 - u, err := user.Current() 28 + c, err := gap.NewScope(gap.User, "app").CacheDir() 27 29 if err != nil { 28 - return "", fmt.Errorf("could not get current user: %w", err) 30 + return "", fmt.Errorf("error getting user home directory: %w", err) 29 31 } 30 - dir = filepath.Join(u.HomeDir, DefaultChunkDir) 32 + dir = filepath.Join(c, DefaultChunkDir) 31 33 } 32 34 if err := os.MkdirAll(dir, 0755); err != nil { 33 35 return "", fmt.Errorf("could not create chunk's directory %s: %w", dir, err)