From 9843a0b741ae3690cd56bdad538f2cf35ccb2903 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 2 Mar 2023 11:47:07 -0500 Subject: [PATCH] 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 --- cmd/dump.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/dump.go b/cmd/dump.go index c879d2fbee..600ec4f32e 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -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) }