|
|
|
@ -1123,16 +1123,22 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error) |
|
|
|
|
return ErrRepoAlreadyExist{u.Name, newRepoName} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
repo, err := GetRepositoryByName(u.Id, oldRepoName) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("GetRepositoryByName: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Change repository directory name.
|
|
|
|
|
if err = os.Rename(RepoPath(u.Name, oldRepoName), RepoPath(u.Name, newRepoName)); err != nil { |
|
|
|
|
if err = os.Rename(repo.RepoPath(), RepoPath(u.Name, newRepoName)); err != nil { |
|
|
|
|
return fmt.Errorf("rename repository directory: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wikiPath := WikiPath(u.Name, oldRepoName) |
|
|
|
|
wikiPath := repo.WikiPath() |
|
|
|
|
if com.IsExist(wikiPath) { |
|
|
|
|
if err = os.Rename(wikiPath, WikiPath(u.Name, newRepoName)); err != nil { |
|
|
|
|
return fmt.Errorf("rename repository wiki: %v", err) |
|
|
|
|
} |
|
|
|
|
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
@ -1295,30 +1301,16 @@ func DeleteRepository(uid, repoID int64) error { |
|
|
|
|
|
|
|
|
|
// Remove repository files.
|
|
|
|
|
repoPath := repo.repoPath(sess) |
|
|
|
|
if err = os.RemoveAll(repoPath); err != nil { |
|
|
|
|
desc := fmt.Sprintf("delete repository files [%s]: %v", repoPath, err) |
|
|
|
|
log.Warn(desc) |
|
|
|
|
if err = CreateRepositoryNotice(desc); err != nil { |
|
|
|
|
log.Error(4, "CreateRepositoryNotice: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RemoveAllWithNotice("Delete repository files", repoPath) |
|
|
|
|
|
|
|
|
|
wikiPaths := []string{repo.WikiPath(), repo.LocalWikiPath()} |
|
|
|
|
for _, wikiPath := range wikiPaths { |
|
|
|
|
if err = os.RemoveAll(wikiPath); err != nil { |
|
|
|
|
desc := fmt.Sprintf("delete repository wiki [%s]: %v", wikiPath, err) |
|
|
|
|
log.Warn(desc) |
|
|
|
|
if err = CreateRepositoryNotice(desc); err != nil { |
|
|
|
|
log.Error(4, "CreateRepositoryNotice: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RemoveAllWithNotice("Delete repository wiki", wikiPath) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove attachment files.
|
|
|
|
|
for i := range attachmentPaths { |
|
|
|
|
if err = os.Remove(attachmentPaths[i]); err != nil { |
|
|
|
|
log.Warn("delete attachment: %v", err) |
|
|
|
|
} |
|
|
|
|
RemoveAllWithNotice("Delete attachment", attachmentPaths[i]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err = sess.Commit(); err != nil { |
|
|
|
@ -1333,7 +1325,7 @@ func DeleteRepository(uid, repoID int64) error { |
|
|
|
|
} |
|
|
|
|
for i := range forkRepos { |
|
|
|
|
if err = DeleteRepository(forkRepos[i].OwnerID, forkRepos[i].ID); err != nil { |
|
|
|
|
log.Error(4, "updateRepository[%d]: %v", forkRepos[i].ID, err) |
|
|
|
|
log.Error(4, "DeleteRepository [%d]: %v", forkRepos[i].ID, err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|