aboutsummaryrefslogtreecommitdiff
path: root/models/repo_transfer.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo_transfer.go')
-rw-r--r--models/repo_transfer.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/models/repo_transfer.go b/models/repo_transfer.go
index f7d5e2099..c6215e682 100644
--- a/models/repo_transfer.go
+++ b/models/repo_transfer.go
@@ -208,10 +208,11 @@ func CreatePendingRepositoryTransfer(doer, newOwner *user_model.User, repoID int
func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_model.Repository) (err error) {
repoRenamed := false
wikiRenamed := false
+ projectBaseRenamed := false
oldOwnerName := doer.Name
defer func() {
- if !repoRenamed && !wikiRenamed {
+ if !repoRenamed && !wikiRenamed && !projectBaseRenamed {
return
}
@@ -234,6 +235,12 @@ func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_mo
}
}
+ if projectBaseRenamed {
+ if err := util.Rename(repo_model.ProjectBasePath(newOwnerName, repo.Name), repo_model.ProjectBasePath(oldOwnerName, repo.Name)); err != nil {
+ log.Critical("Unable to move projectbase for repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, repo_model.ProjectBasePath(newOwnerName, repo.Name), repo_model.ProjectBasePath(oldOwnerName, repo.Name), err)
+ }
+ }
+
if recoverErr != nil {
log.Error("Panic within TransferOwnership: %v\n%s", recoverErr, log.Stack(2))
panic(recoverErr)
@@ -404,6 +411,19 @@ func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_mo
wikiRenamed = true
}
+ // Rename remote projectbase repository to new path and delete local copy.
+ projectBasePath := repo_model.ProjectBasePath(oldOwner.Name, repo.Name)
+
+ if isExist, err := util.IsExist(projectBasePath); err != nil {
+ log.Error("Unable to check if %s exists. Error: %v", projectBasePath, err)
+ return err
+ } else if isExist {
+ if err := util.Rename(projectBasePath, repo_model.ProjectBasePath(newOwner.Name, repo.Name)); err != nil {
+ return fmt.Errorf("rename repository projectbase: %v", err)
+ }
+ projectBaseRenamed = true
+ }
+
if err := deleteRepositoryTransfer(ctx, repo.ID); err != nil {
return fmt.Errorf("deleteRepositoryTransfer: %v", err)
}