From b8d87fec53249fe728ec7f76453d278f5d00d0ef Mon Sep 17 00:00:00 2001 From: Matthias <5011972+fasmat@users.noreply.github.com> Date: Wed, 20 Sep 2023 10:13:10 +0000 Subject: [PATCH] More fixes for windows --- initialization/initialization_test.go | 2 +- initialization/migrate_metadata.go | 4 ++-- initialization/migrate_metadata_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/initialization/initialization_test.go b/initialization/initialization_test.go index a5d96cbef..29dd8717c 100644 --- a/initialization/initialization_test.go +++ b/initialization/initialization_test.go @@ -120,8 +120,8 @@ func TestInitialize_Migrate_Metadata(t *testing.T) { // store in old metadata format f, err := os.Create(filepath.Join(opts.DataDir, MetadataFileName)) require.NoError(t, err) - defer f.Close() require.NoError(t, json.NewEncoder(f).Encode(old)) + require.NoError(t, f.Close()) // just creating a new initializer should update the metadata init, err = NewInitializer( diff --git a/initialization/migrate_metadata.go b/initialization/migrate_metadata.go index db6907952..4f789dffa 100644 --- a/initialization/migrate_metadata.go +++ b/initialization/migrate_metadata.go @@ -157,7 +157,7 @@ func migrateV0(dir string, logger *zap.Logger) (err error) { tmp, err := os.Create(fmt.Sprintf("%s.tmp", filename)) if err != nil { - return fmt.Errorf("create temporary file %s: %w", tmp.Name(), err) + return fmt.Errorf("create temporary file: %w", err) } defer tmp.Close() @@ -170,7 +170,7 @@ func migrateV0(dir string, logger *zap.Logger) (err error) { } if err := atomic.ReplaceFile(tmp.Name(), filename); err != nil { - return fmt.Errorf("save file from %s, %s: %w", tmp.Name(), filename, err) + return fmt.Errorf("atomic replace: %w", err) } return nil diff --git a/initialization/migrate_metadata_test.go b/initialization/migrate_metadata_test.go index 8d41d25e1..da284702f 100644 --- a/initialization/migrate_metadata_test.go +++ b/initialization/migrate_metadata_test.go @@ -99,8 +99,8 @@ func Test_Migrate_Adds_NonceValue(t *testing.T) { path := t.TempDir() f, err := os.Create(filepath.Join(path, MetadataFileName)) require.NoError(t, err) - defer f.Close() require.NoError(t, json.NewEncoder(f).Encode(old)) + require.NoError(t, f.Close()) log := zaptest.NewLogger(t) require.NoError(t, MigratePoST(path, log))