diff options
author | zeripath <art27@cantab.net> | 2020-08-11 21:05:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 21:05:34 +0100 |
commit | 74bd9691c685942798f2761607731697498ceeae (patch) | |
tree | 531d661263b839ccf8aa6af73bfb6710984f0dd9 /modules/repository/generate.go | |
parent | faa676cc8b4419ac56fbf9d009ea8c6b79834024 (diff) | |
download | gitea-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 'modules/repository/generate.go')
-rw-r--r-- | modules/repository/generate.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go index 6d80488de7..c5fb0af383 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/util" "github.com/huandu/xstrings" ) @@ -119,7 +120,7 @@ func generateRepoCommit(repo, templateRepo, generateRepo *models.Repository, tmp return fmt.Errorf("git clone: %v", err) } - if err := os.RemoveAll(path.Join(tmpDir, ".git")); err != nil { + if err := util.RemoveAll(path.Join(tmpDir, ".git")); err != nil { return fmt.Errorf("remove git dir: %v", err) } @@ -130,7 +131,7 @@ func generateRepoCommit(repo, templateRepo, generateRepo *models.Repository, tmp } if gt != nil { - if err := os.Remove(gt.Path); err != nil { + if err := util.Remove(gt.Path); err != nil { return fmt.Errorf("remove .giteatemplate: %v", err) } @@ -191,7 +192,7 @@ func generateGitContent(ctx models.DBContext, repo, templateRepo, generateRepo * } defer func() { - if err := os.RemoveAll(tmpDir); err != nil { + if err := util.RemoveAll(tmpDir); err != nil { log.Error("RemoveAll: %v", err) } }() |