From dcdb1605b0e7c89666602a9d46ac3e605cc22069 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 11 Aug 2014 23:15:38 -0700 Subject: [PATCH] fixed issue where not correctly adding perm for existing repo --- server/handler/login.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/handler/login.go b/server/handler/login.go index 3043283ae..615f4d9a1 100644 --- a/server/handler/login.go +++ b/server/handler/login.go @@ -129,12 +129,13 @@ func (h *LoginHandler) GetLogin(w http.ResponseWriter, r *http.Request) error { repo.URL = remoteRepo.URL if err := h.repos.Insert(repo); err != nil { - log.Println("Error adding repo.", u.Login, remoteRepo.Name, err) - // this is probably because the repository already exists. - // we should still attempt to grant the user access, however. - // - // todo(bradrydzewski) we should inspect the response to ensure - // the failure is caused by a primary key violation. + // typically we see a failure because the repository already exists + // in which case, we can retrieve the existing record to get the ID. + repo, err = h.repos.FindName(repo.Host, repo.Owner, repo.Name) + if err != nil { + log.Println("Error adding repo.", u.Login, remoteRepo.Name, err) + continue + } } // add user permissions