Browse Source

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

for-closed-social
SagePtr 6 years ago
committed by techknowlogick
parent
commit
303d7f7e9c
2 changed files with 6 additions and 7 deletions
  1. +0
    -4
      models/org.go
  2. +6
    -3
      models/user.go

+ 0
- 4
models/org.go View File

@ -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()
}

+ 6
- 3
models/user.go View File

@ -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()
@ -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

Loading…
Cancel
Save