Skip to content

Commit c05087e

Browse files
cfergeaupraveenkumar
authored andcommitted
cache: Remove Cache.destDir
It's always set to constants.BinDir() and is only used in CacheExecutable(), we can directly use constants.BinDir() there.
1 parent 20a02e6 commit c05087e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/crc/cache/cache.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
type Cache struct {
2020
executablePath string
2121
archiveURL string
22-
destDir string
2322
version string
2423
getVersion func(string) (string, error)
2524
}
@@ -35,7 +34,7 @@ func (e *VersionMismatchError) Error() string {
3534
}
3635

3736
func New(executablePath string, archiveURL string, version string, getVersion func(string) (string, error)) *Cache {
38-
return &Cache{executablePath: executablePath, archiveURL: archiveURL, destDir: constants.BinDir(), version: version, getVersion: getVersion}
37+
return &Cache{executablePath: executablePath, archiveURL: archiveURL, version: version, getVersion: getVersion}
3938
}
4039

4140
func (c *Cache) GetExecutablePath() string {
@@ -134,13 +133,13 @@ func (c *Cache) CacheExecutable() error {
134133
}
135134

136135
// Copy the requested asset into its final destination
137-
err = os.MkdirAll(c.destDir, 0750)
136+
err = os.MkdirAll(constants.BinDir(), 0750)
138137
if err != nil {
139138
return errors.Wrap(err, "cannot create the target directory")
140139
}
141140

142141
for _, extractedFilePath := range extractedFiles {
143-
finalExecutablePath := filepath.Join(c.destDir, filepath.Base(extractedFilePath))
142+
finalExecutablePath := filepath.Join(constants.BinDir(), filepath.Base(extractedFilePath))
144143
// If the file exists then remove it (ignore error) first before copy because with `0500` permission
145144
// it is not possible to overwrite the file.
146145
os.Remove(finalExecutablePath)

0 commit comments

Comments
 (0)