From 01066c72b5a3f3881ff71dd31bf851151d34d737 Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Wed, 10 May 2017 13:11:09 +0800 Subject: [PATCH] update --- src/ui/api/project.go | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/ui/api/project.go b/src/ui/api/project.go index b151d3097..93243fe7a 100644 --- a/src/ui/api/project.go +++ b/src/ui/api/project.go @@ -119,27 +119,29 @@ func (p *ProjectAPI) Post() { return } - user, err := dao.GetUser(models.User{ - UserID: p.userID, - }) - if err != nil { - log.Errorf("failed to get user by ID %d: %v", p.userID, err) - p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) - } + go func() { + user, err := dao.GetUser(models.User{ + UserID: p.userID, + }) + if err != nil { + log.Errorf("failed to get user by ID %d: %v", p.userID, err) + p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) + } - accessLog := models.AccessLog{ - Username: user.Username, - ProjectID: projectID, - RepoName: project.Name + "/", - RepoTag: "N/A", - GUID: "N/A", - Operation: "create", - OpTime: time.Now(), - } - if err = dao.AddAccessLog(accessLog); err != nil { - log.Errorf("failed to add access log: %v", err) - p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) - } + accessLog := models.AccessLog{ + Username: user.Username, + ProjectID: projectID, + RepoName: project.Name + "/", + RepoTag: "N/A", + GUID: "N/A", + Operation: "create", + OpTime: time.Now(), + } + if err = dao.AddAccessLog(accessLog); err != nil { + log.Errorf("failed to add access log: %v", err) + p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) + } + }() p.Redirect(http.StatusCreated, strconv.FormatInt(projectID, 10)) }