Close the temp file when dumping database to make the temp file can be deleted on Windows (#23249) (#23251)

Backport #23249

There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2023-03-02 11:47:07 -05:00 committed by GitHub
parent 085a4debd5
commit 9843a0b741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}