aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_transfer.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-07-15 16:46:07 +0100
committerGitHub <noreply@github.com>2021-07-15 11:46:07 -0400
commit33a8eec33e975a74f1718a83e99eb6abc7662a19 (patch)
treed000ff3f37d417e9d03d15d070ed6fecf9c56636 /models/repo_transfer.go
parentaed086f8b021f5724ff1449ceb9f44dc28749a97 (diff)
downloadgitea-33a8eec33e975a74f1718a83e99eb6abc7662a19.tar.gz
gitea-33a8eec33e975a74f1718a83e99eb6abc7662a19.zip
Retry rename on lock induced failures (#16435)
* Retry rename on lock induced failures Due to external locking on Windows it is possible for an os.Rename to fail if the files or directories are being used elsewhere. This PR simply suggests retrying the rename again similar to how we handle the os.Remove problems. Fix #16427 Signed-off-by: Andrew Thornton <art27@cantab.net> * resolve CI fail Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models/repo_transfer.go')
-rw-r--r--models/repo_transfer.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/models/repo_transfer.go b/models/repo_transfer.go
index c5d1a3a3c2..d7ef0a8ca6 100644
--- a/models/repo_transfer.go
+++ b/models/repo_transfer.go
@@ -210,13 +210,13 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
}
if repoRenamed {
- if err := os.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil {
+ if err := util.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil {
log.Critical("Unable to move repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name), err)
}
}
if wikiRenamed {
- if err := os.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil {
+ if err := util.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil {
log.Critical("Unable to move wiki for repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name), err)
}
}
@@ -358,7 +358,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
- if err := os.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
+ if err := util.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository directory: %v", err)
}
repoRenamed = true
@@ -370,7 +370,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
log.Error("Unable to check if %s exists. Error: %v", wikiPath, err)
return err
} else if isExist {
- if err := os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
+ if err := util.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository wiki: %v", err)
}
wikiRenamed = true