From 0cdbd1d7a6ad057742c59cc56c471240be6fdd88 Mon Sep 17 00:00:00 2001 From: Bartosz Popiela Date: Wed, 8 May 2024 23:53:22 +0200 Subject: [PATCH] Fix "crane layout gc" failing on Windows wit "Error: cannot parse hash: "sha256\\0401ae60059.." (#1942) --- pkg/v1/layout/gc.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/v1/layout/gc.go b/pkg/v1/layout/gc.go index 5fdb2c05d..6d001bd4d 100644 --- a/pkg/v1/layout/gc.go +++ b/pkg/v1/layout/gc.go @@ -18,6 +18,7 @@ package layout import ( "fmt" "io/fs" + "os" "path/filepath" "strings" @@ -54,7 +55,7 @@ func (l Path) GarbageCollect() ([]v1.Hash, error) { if err != nil { return err } - hashString := strings.Replace(rel, "/", ":", 1) + hashString := strings.Replace(rel, string(os.PathSeparator), ":", 1) if present := blobsToKeep[hashString]; !present { h, err := v1.NewHash(hashString) if err != nil {