aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/dump.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-08-11 21:05:34 +0100
committerGitHub <noreply@github.com>2020-08-11 21:05:34 +0100
commit74bd9691c685942798f2761607731697498ceeae (patch)
tree531d661263b839ccf8aa6af73bfb6710984f0dd9 /cmd/dump.go
parentfaa676cc8b4419ac56fbf9d009ea8c6b79834024 (diff)
downloadgitea-74bd9691c685942798f2761607731697498ceeae.tar.gz
gitea-74bd9691c685942798f2761607731697498ceeae.zip
Re-attempt to delete temporary upload if the file is locked by another process (#12447)
Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util. Fix #12339 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'cmd/dump.go')
-rw-r--r--cmd/dump.go9
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)
}