Skip to content

Commit

Permalink
Close the temp file when dumping database to make the temp file can b…
Browse files Browse the repository at this point in the history
…e deleted on Windows (#23249)

There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.
  • Loading branch information
wxiaoguang authored Mar 2, 2023
1 parent ea1d097 commit 294124d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to create tmp file: %v", err)
}
defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
}
Expand Down

0 comments on commit 294124d

Please sign in to comment.