Skip to content

Commit

Permalink
delete: remove only backup log files when deleting cache
Browse files Browse the repository at this point in the history
currently after #3720 was merged it is deleting the
'crc.log' and 'crcd.log' files and not deleting the backups

this adds deletion of the backed up log files named crc-*.log
and removes deletion of the crc.log file which is handled  by
'crc cleanup'

it removes the deletion of crcd.log file as when delete is
performed the daemon still keeps running in the background
  • Loading branch information
anjannath authored and praveenkumar committed Aug 8, 2023
1 parent 9066ef8 commit 0a7e24f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/crc/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"fmt"
"io"
"os"
"path/filepath"

"github.com/crc-org/crc/pkg/crc/constants"
crcErrors "github.com/crc-org/crc/pkg/crc/errors"
"github.com/crc-org/crc/pkg/crc/input"
"github.com/crc-org/crc/pkg/crc/logging"
"github.com/crc-org/crc/pkg/crc/machine"
crcos "github.com/crc-org/crc/pkg/os"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -41,9 +43,10 @@ func deleteMachine(client machine.Client, clearCache bool, cacheDir string, inte
yes := input.PromptUserForYesOrNo("Do you want to delete the instance cache", force)
if yes {
_ = os.RemoveAll(cacheDir)
// also delete the crc.log and crcd.log files
_ = os.Remove(constants.LogFilePath)
_ = os.Remove(constants.DaemonLogFilePath)
// also delete the crc-*.log files
if err := crcos.RemoveFileGlob(filepath.Join(constants.CrcBaseDir, "crc-*.log")); err != nil {
logging.Debug("Failed to find log files: ", err)
}
}
}

Expand Down

0 comments on commit 0a7e24f

Please sign in to comment.