Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not autocreate directory for new users/orgs (#4828) #4849

Merged
merged 2 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ func CreateOrganization(org, owner *User) (err error) {
return fmt.Errorf("insert team-user relation: %v", err)
}

if err = os.MkdirAll(UserPath(org.Name), os.ModePerm); err != nil {
return fmt.Errorf("create directory: %v", err)
}

return sess.Commit()
}

Expand Down
9 changes: 6 additions & 3 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,6 @@ func CreateUser(u *User) (err error) {

if _, err = sess.Insert(u); err != nil {
return err
} else if err = os.MkdirAll(UserPath(u.Name), os.ModePerm); err != nil {
return err
}

return sess.Commit()
Expand Down Expand Up @@ -898,7 +896,12 @@ func ChangeUserName(u *User, newUserName string) (err error) {
return fmt.Errorf("Delete repository wiki local copy: %v", err)
}

return os.Rename(UserPath(u.Name), UserPath(newUserName))
// Do not fail if directory does not exist
if err = os.Rename(UserPath(u.Name), UserPath(newUserName)); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Rename user directory: %v", err)
}

return nil
}

// checkDupEmail checks whether there are the same email with the user
Expand Down