From df52f86cf36d7f0a1ac4cfe268ec5ffbc3026e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rold=C3=A1n=20Betancort?= Date: Fri, 19 Jan 2024 18:16:39 +0000 Subject: [PATCH] fixes bug where redacted files would be corrupted as the Avro encoder wasn't being flushed and the file may have been partially written --- internal/cmd/backup.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cmd/backup.go b/internal/cmd/backup.go index 5181de33..d19a35ec 100644 --- a/internal/cmd/backup.go +++ b/internal/cmd/backup.go @@ -501,6 +501,8 @@ func backupRedactCmdFunc(cmd *cobra.Command, args []string) error { return err } + defer func(e *error) { *e = errors.Join(*e, writer.Close()) }(&err) + redactor, err := backupformat.NewRedactor(decoder, writer, backupformat.RedactionOptions{ RedactDefinitions: cobrautil.MustGetBool(cmd, "redact-definitions"), RedactRelations: cobrautil.MustGetBool(cmd, "redact-relations"), @@ -510,6 +512,7 @@ func backupRedactCmdFunc(cmd *cobra.Command, args []string) error { return fmt.Errorf("error creating redactor: %w", err) } + defer func(e *error) { *e = errors.Join(*e, redactor.Close()) }(&err) bar := relProgressBar("redacting backup") var written int64 for {