forked from forgejo/forgejo
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:
parent
faa676cc8b
commit
74bd9691c6
60 changed files with 304 additions and 202 deletions
|
@ -15,6 +15,8 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
// FileLogger implements LoggerProvider.
|
||||
|
@ -214,11 +216,11 @@ func compressOldLogFile(fname string, compressionLevel int) error {
|
|||
if err != nil {
|
||||
zw.Close()
|
||||
fw.Close()
|
||||
os.Remove(fname + ".gz")
|
||||
util.Remove(fname + ".gz")
|
||||
return err
|
||||
}
|
||||
reader.Close()
|
||||
return os.Remove(fname)
|
||||
return util.Remove(fname)
|
||||
}
|
||||
|
||||
func (log *FileLogger) deleteOldLog() {
|
||||
|
@ -233,7 +235,7 @@ func (log *FileLogger) deleteOldLog() {
|
|||
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*log.Maxdays) {
|
||||
if strings.HasPrefix(filepath.Base(path), filepath.Base(log.Filename)) {
|
||||
|
||||
if err := os.Remove(path); err != nil {
|
||||
if err := util.Remove(path); err != nil {
|
||||
returnErr = fmt.Errorf("Failed to remove %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue