aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-03 02:08:25 -0500
committerUnknwon <u@gogs.io>2015-12-03 02:08:25 -0500
commit37a372f6f57d3c59364af2ed0fc21a58e31146d2 (patch)
tree11c6631d32ecb7fd7af9698b54e58d197f8a169f /models
parentf122d0856eb4d414c975c404333bca4d65775821 (diff)
downloadgitea-37a372f6f57d3c59364af2ed0fc21a58e31146d2.tar.gz
gitea-37a372f6f57d3c59364af2ed0fc21a58e31146d2.zip
500 when wiki not exists
Diffstat (limited to 'models')
-rw-r--r--models/repo.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index c16a96f110..772551db88 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -985,8 +985,13 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
// Change repository directory name.
if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository directory: %v", err)
- } else if err = os.Rename(WikiPath(owner.Name, repo.Name), WikiPath(newOwner.Name, repo.Name)); err != nil {
- return fmt.Errorf("rename repository wiki: %v", err)
+ }
+
+ wikiPath := WikiPath(owner.Name, repo.Name)
+ if com.IsExist(wikiPath) {
+ if err = os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
+ return fmt.Errorf("rename repository wiki: %v", err)
+ }
}
return sess.Commit()
@@ -1014,9 +1019,12 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
wikiPath := WikiPath(u.Name, oldRepoName)
if com.IsExist(wikiPath) {
- err = os.Rename(WikiPath(u.Name, oldRepoName), WikiPath(u.Name, newRepoName))
+ if err = os.Rename(wikiPath, WikiPath(u.Name, newRepoName)); err != nil {
+ return fmt.Errorf("rename repository wiki: %v", err)
+ }
}
- return err
+
+ return nil
}
func getRepositoriesByForkID(e Engine, forkID int64) ([]*Repository, error) {