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/markup | |
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/markup')
-rw-r--r-- | modules/markup/external/external.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index 02cf61be16..7acf936171 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" ) // RegisterParsers registers all supported third part parsers according settings @@ -70,7 +71,12 @@ func (p *Parser) Render(rawBytes []byte, urlPrefix string, metas map[string]stri log.Error("%s create temp file when rendering %s failed: %v", p.Name(), p.Command, err) return []byte("") } - defer os.Remove(f.Name()) + tmpPath := f.Name() + defer func() { + if err := util.Remove(tmpPath); err != nil { + log.Warn("Unable to remove temporary file: %s: Error: %v", tmpPath, err) + } + }() _, err = io.Copy(f, rd) if err != nil { |