summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagePtr <sageptr@gmail.com>2018-09-07 02:40:58 +0200
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-09-06 20:40:58 -0400
commit303d7f7e9cfadf92e37dc44fb7f7c08164637773 (patch)
treea4cde3f54498dbec58baabec9675b3721db1b6f4
parent3c6cc56143d6ef4b12c0c9c998951c2f66bfbfd9 (diff)
downloadgitea-303d7f7e9cfadf92e37dc44fb7f7c08164637773.tar.gz
gitea-303d7f7e9cfadf92e37dc44fb7f7c08164637773.zip
Do not autocreate directory for new user/orgs (#4828) (#4849)
-rw-r--r--models/org.go4
-rw-r--r--models/user.go9
2 files changed, 6 insertions, 7 deletions
diff --git a/models/org.go b/models/org.go
index a62c67deb7..1cc25231e6 100644
--- a/models/org.go
+++ b/models/org.go
@@ -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()
}
diff --git a/models/user.go b/models/user.go
index a68b23568b..11cbdb2f45 100644
--- a/models/user.go
+++ b/models/user.go
@@ -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