@@ -17,14 +17,12 @@ package cache
1717
1818import (
1919 "os"
20- "path/filepath"
21- "runtime"
2220
2321 "github.com/arduino/arduino-cli/cli/errorcodes"
2422 "github.com/arduino/arduino-cli/cli/feedback"
25- "github.com/arduino/go-win32-utils"
2623 "github.com/sirupsen/logrus"
2724 "github.com/spf13/cobra"
25+ "github.com/spf13/viper"
2826)
2927
3028func initCleanCommand () * cobra.Command {
@@ -42,34 +40,10 @@ func initCleanCommand() *cobra.Command {
4240func runCleanCommand (cmd * cobra.Command , args []string ) {
4341 logrus .Info ("Executing `arduino cache clean`" )
4442
45- cachePath := getDefaultArduinoDataDir () + "/staging"
43+ cachePath := viper . GetString ( "directories.Downloads" )
4644 err := os .RemoveAll (cachePath )
4745 if err != nil {
4846 feedback .Errorf ("Error cleaning caches: %v" , err )
4947 os .Exit (errorcodes .ErrGeneric )
5048 }
5149}
52-
53- func getDefaultArduinoDataDir () string {
54- userHomeDir , err := os .UserHomeDir ()
55- if err != nil {
56- feedback .Errorf ("Unable to get user home dir: %v" , err )
57- return "."
58- }
59-
60- switch runtime .GOOS {
61- case "linux" :
62- return filepath .Join (userHomeDir , ".arduino15" )
63- case "darwin" :
64- return filepath .Join (userHomeDir , "Library" , "Arduino15" )
65- case "windows" :
66- localAppDataPath , err := win32 .GetLocalAppDataFolder ()
67- if err != nil {
68- feedback .Errorf ("Unable to get Local App Data Folder: %v" , err )
69- return "."
70- }
71- return filepath .Join (localAppDataPath , "Arduino15" )
72- default :
73- return "."
74- }
75- }
0 commit comments