Skip to content

Commit

Permalink
fixes bug where redacted files would be corrupted
Browse files Browse the repository at this point in the history
as the Avro encoder wasn't being flushed and
the file may have been partially written
  • Loading branch information
vroldanbet committed Jan 19, 2024
1 parent 94c8811 commit df52f86
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 {
Expand Down

0 comments on commit df52f86

Please sign in to comment.