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 /models/repo.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 'models/repo.go')
-rw-r--r-- | models/repo.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go index b2b6e1a26f..9f7ce8af1e 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1440,7 +1440,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e // Create/Remove git-daemon-export-ok for git-daemon... daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`) if repo.IsPrivate && com.IsExist(daemonExportFile) { - if err = os.Remove(daemonExportFile); err != nil { + if err = util.Remove(daemonExportFile); err != nil { log.Error("Failed to remove %s: %v", daemonExportFile, err) } } else if !repo.IsPrivate && !com.IsExist(daemonExportFile) { @@ -1708,7 +1708,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error { if len(repo.Avatar) > 0 { avatarPath := repo.CustomAvatarPath() if com.IsExist(avatarPath) { - if err := os.Remove(avatarPath); err != nil { + if err := util.Remove(avatarPath); err != nil { return fmt.Errorf("Failed to remove %s: %v", avatarPath, err) } } @@ -1852,7 +1852,7 @@ func DeleteRepositoryArchives(ctx context.Context) error { return ErrCancelledf("before deleting repository archives for %s", repo.FullName()) default: } - return os.RemoveAll(filepath.Join(repo.RepoPath(), "archives")) + return util.RemoveAll(filepath.Join(repo.RepoPath(), "archives")) }) } @@ -1911,7 +1911,7 @@ func deleteOldRepositoryArchives(ctx context.Context, olderThan time.Duration, i } toDelete := filepath.Join(path, info.Name()) // This is a best-effort purge, so we do not check error codes to confirm removal. - if err = os.Remove(toDelete); err != nil { + if err = util.Remove(toDelete); err != nil { log.Trace("Unable to delete %s, but proceeding: %v", toDelete, err) } } @@ -2280,7 +2280,7 @@ func (repo *Repository) UploadAvatar(data []byte) error { } if len(oldAvatarPath) > 0 && oldAvatarPath != repo.CustomAvatarPath() { - if err := os.Remove(oldAvatarPath); err != nil { + if err := util.Remove(oldAvatarPath); err != nil { return fmt.Errorf("UploadAvatar: Failed to remove old repo avatar %s: %v", oldAvatarPath, err) } } @@ -2311,7 +2311,7 @@ func (repo *Repository) DeleteAvatar() error { } if _, err := os.Stat(avatarPath); err == nil { - if err := os.Remove(avatarPath); err != nil { + if err := util.Remove(avatarPath); err != nil { return fmt.Errorf("DeleteAvatar: Failed to remove %s: %v", avatarPath, err) } } else { |