Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 09:54:24 +01:00

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

There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.
This commit is contained in:
wxiaoguang 2023-03-02 23:57:31 +08:00 committed by GitHub
parent ea1d09718c
commit 294124d129
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) fatal("Failed to create tmp file: %v", err)
} }
defer func() { defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil { if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err) log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
} }