Explorar el Código

#2334 strip whitespace for migrate URL

Also fix a possible race condition while install
Unknwon hace 9 años
padre
commit
926e75d721
Se han modificado 2 ficheros con 5 adiciones y 2 borrados
  1. 1 1
      modules/auth/repo_form.go
  2. 4 1
      modules/mailer/mailer.go

+ 1 - 1
modules/auth/repo_form.go

@@ -57,7 +57,7 @@ func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bi
 // It also checks if given user has permission when remote address
 // It also checks if given user has permission when remote address
 // is actually a local path.
 // is actually a local path.
 func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) {
 func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) {
-	remoteAddr := f.CloneAddr
+	remoteAddr := strings.TrimSpace(f.CloneAddr)
 
 
 	// Remote address can be HTTP/HTTPS/Git URL or local path.
 	// Remote address can be HTTP/HTTPS/Git URL or local path.
 	if strings.HasPrefix(remoteAddr, "http://") ||
 	if strings.HasPrefix(remoteAddr, "http://") ||

+ 4 - 1
modules/mailer/mailer.go

@@ -197,7 +197,10 @@ func processMailQueue() {
 var mailQueue chan *Message
 var mailQueue chan *Message
 
 
 func NewContext() {
 func NewContext() {
-	if setting.MailService == nil {
+	// Need to check if mailQueue is nil because in during reinstall (user had installed
+	// before but swithed install lock off), this function will be called again
+	// while mail queue is already processing tasks, and produces a race condition.
+	if setting.MailService == nil || mailQueue != nil {
 		return
 		return
 	}
 	}