From cac76de3f01a02579e3771777c821fc9efaac632 Mon Sep 17 00:00:00 2001 From: Alberto Faria Date: Mon, 22 Apr 2024 21:58:45 +0100 Subject: [PATCH] Base ISO cache file name on the full ISO URL Currently, only the final component of the URL path is used. This means that minikube may use the wrong cached image after the user changes the ISO URL to another with the same final component. Fix this by suffixing the cache file name with a hash of the entire URL. Signed-off-by: Alberto Faria --- pkg/minikube/download/iso.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/download/iso.go b/pkg/minikube/download/iso.go index 6d5f9fe4f2fc..96e6506e4de7 100644 --- a/pkg/minikube/download/iso.go +++ b/pkg/minikube/download/iso.go @@ -17,6 +17,7 @@ limitations under the License. package download import ( + "crypto/sha1" "fmt" "net/url" "os" @@ -77,7 +78,10 @@ func localISOPath(u *url.URL) string { return u.String() } - return filepath.Join(detect.ISOCacheDir(), path.Base(u.Path)) + urlHash := sha1.Sum([]byte(u.String())) + fileName := fmt.Sprintf("%s-%040x", path.Base(u.Path), urlHash) + + return filepath.Join(detect.ISOCacheDir(), fileName) } // ISO downloads and returns the path to the downloaded ISO