summaryrefslogtreecommitdiffstats
path: root/modules/lfs
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 /modules/lfs
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 'modules/lfs')
-rw-r--r--modules/lfs/content_store.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go
index 6ad565178c..b0fa77e255 100644
--- a/modules/lfs/content_store.go
+++ b/modules/lfs/content_store.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/util"
)
var (
@@ -61,7 +62,11 @@ func (s *ContentStore) Put(meta *models.LFSMetaObject, r io.Reader) error {
log.Error("Whilst putting LFS OID[%s]: Unable to open temporary file for writing: %s Error: %v", tmpPath, err)
return err
}
- defer os.Remove(tmpPath)
+ defer func() {
+ if err := util.Remove(tmpPath); err != nil {
+ log.Warn("Unable to remove temporary path: %s: Error: %v", tmpPath, err)
+ }
+ }()
hash := sha256.New()
hw := io.MultiWriter(hash, file)