mirror of
https://github.com/go-gitea/gitea
synced 2025-07-03 09:07:19 +00:00
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>
This commit is contained in:
8
modules/markup/external/external.go
vendored
8
modules/markup/external/external.go
vendored
@ -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 {
|
||||
|
Reference in New Issue
Block a user