mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-23 09:30:50 +00:00
#2558 delete local wiki copy when rename repo and user
This commit is contained in:
parent
4e96a4a62b
commit
f8182ac521
6 changed files with 40 additions and 25 deletions
|
@ -598,11 +598,19 @@ func ChangeUserName(u *User, newUserName string) (err error) {
|
|||
return ErrUserAlreadyExist{newUserName}
|
||||
}
|
||||
|
||||
err = ChangeUsernameInPullRequests(u.Name, newUserName)
|
||||
if err != nil {
|
||||
if err = ChangeUsernameInPullRequests(u.Name, newUserName); err != nil {
|
||||
return fmt.Errorf("ChangeUsernameInPullRequests: %v", err)
|
||||
}
|
||||
|
||||
// Delete all local copies of repository wiki that user owns.
|
||||
if err = x.Where("owner_id=?", u.Id).Iterate(new(Repository), func(idx int, bean interface{}) error {
|
||||
repo := bean.(*Repository)
|
||||
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("Delete repository wiki local copy: %v", err)
|
||||
}
|
||||
|
||||
return os.Rename(UserPath(u.Name), UserPath(newUserName))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue