diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/doctor.go | 3 | ||||
-rw-r--r-- | cmd/dump.go | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/cmd/doctor.go b/cmd/doctor.go index 48fd3158a4..20c1904afa 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" "github.com/urfave/cli" @@ -312,7 +313,7 @@ func runDoctorWritableDir(path string) error { if err != nil { return err } - if err := os.Remove(tmpFile.Name()); err != nil { + if err := util.Remove(tmpFile.Name()); err != nil { fmt.Printf("Warning: can't remove temporary file: '%s'\n", tmpFile.Name()) } tmpFile.Close() 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) } |