diff options
Diffstat (limited to 'cmd/dump.go')
-rw-r--r-- | cmd/dump.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index dd259575fa..c647341221 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "gitea.com/macaron/session" archiver "github.com/mholt/archiver/v3" @@ -243,7 +244,11 @@ func runDump(ctx *cli.Context) error { if err != nil { fatal("Failed to create tmp file: %v", err) } - defer os.Remove(dbDump.Name()) + defer func() { + if err := util.Remove(dbDump.Name()); err != nil { + log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err) + } + }() targetDBType := ctx.String("database") if len(targetDBType) > 0 && targetDBType != setting.Database.Type { @@ -313,7 +318,7 @@ func runDump(ctx *cli.Context) error { if fileName != "-" { if err = w.Close(); err != nil { - _ = os.Remove(fileName) + _ = util.Remove(fileName) fatal("Failed to save %s: %v", fileName, err) } |