diff --git a/revocation/crl/cache/file.go b/revocation/crl/cache/file.go index 6c77b7ab..16087235 100644 --- a/revocation/crl/cache/file.go +++ b/revocation/crl/cache/file.go @@ -115,11 +115,10 @@ func (c *FileCache) Set(ctx context.Context, uri string, bundle *Bundle) error { if err != nil { return err } - defer tempFile.Close() - if err := saveTar(tempFile, bundle); err != nil { return err } + tempFile.Close() // rename is atomic on UNIX-like platforms return os.Rename(tempFile.Name(), filepath.Join(c.root, fileName(uri))) diff --git a/revocation/crl/cache/file_test.go b/revocation/crl/cache/file_test.go index 97d63506..05d8c683 100644 --- a/revocation/crl/cache/file_test.go +++ b/revocation/crl/cache/file_test.go @@ -23,6 +23,7 @@ import ( "math/big" "os" "path/filepath" + "runtime" "strings" "testing" "time" @@ -92,6 +93,10 @@ func TestFileCache(t *testing.T) { func TestNewFileCache(t *testing.T) { tempDir := t.TempDir() t.Run("without permission to create cache directory", func(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("skipping test on Windows") + } + if err := os.Chmod(tempDir, 0); err != nil { t.Fatalf("failed to change permission: %v", err) }