File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed
Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ package bundle
22
33import (
44 "os"
5+ "path/filepath"
56 "strings"
67
78 "github.com/crc-org/crc/v2/pkg/crc/constants"
89 "github.com/crc-org/crc/v2/pkg/crc/logging"
9- "github.com/crc-org/crc/v2/pkg/extract"
1010 "github.com/spf13/cobra"
1111)
1212
@@ -37,13 +37,10 @@ func runClear() error {
3737 var lastErr error
3838 for _ , file := range files {
3939 if strings .HasSuffix (file .Name (), ".crcbundle" ) {
40- filePath , err := extract .BuildPathChecked (cacheDir , file .Name ())
41- if err != nil {
42- logging .Errorf ("Skipping unsafe path %s: %v" , file .Name (), err )
43- continue
44- }
40+ safeName := filepath .Base (file .Name ())
41+ filePath := filepath .Join (cacheDir , safeName )
4542 logging .Infof ("Deleting %s" , filePath )
46- if err := os .RemoveAll (filePath ); err != nil {
43+ if err := os .Remove (filePath ); err != nil {
4744 logging .Errorf ("Failed to remove %s: %v" , filePath , err )
4845 lastErr = err
4946 } else {
Original file line number Diff line number Diff line change @@ -3,14 +3,14 @@ package bundle
33import (
44 "fmt"
55 "os"
6+ "path/filepath"
67 "regexp"
78 "sort"
89 "strconv"
910 "strings"
1011
1112 "github.com/crc-org/crc/v2/pkg/crc/constants"
1213 "github.com/crc-org/crc/v2/pkg/crc/logging"
13- "github.com/crc-org/crc/v2/pkg/extract"
1414 "github.com/spf13/cobra"
1515)
1616
@@ -110,13 +110,10 @@ func runPrune(keep int) error {
110110 })
111111
112112 for i := keep ; i < len (bundles ); i ++ {
113- filePath , err := extract .BuildPathChecked (cacheDir , bundles [i ].name )
114- if err != nil {
115- logging .Errorf ("Skipping unsafe path %s: %v" , bundles [i ].name , err )
116- continue
117- }
118- logging .Infof ("Pruning old bundle: %s" , bundles [i ].name )
119- if err := os .RemoveAll (filePath ); err != nil {
113+ safeName := filepath .Base (bundles [i ].name )
114+ filePath := filepath .Join (cacheDir , safeName )
115+ logging .Infof ("Pruning old bundle: %s" , safeName )
116+ if err := os .Remove (filePath ); err != nil {
120117 logging .Errorf ("Failed to remove %s: %v" , filePath , err )
121118 }
122119 pruned = true
You can’t perform that action at this time.
0 commit comments