This commit is contained in:
Wenkai Yin 2017-05-10 13:11:09 +08:00
parent 6cf545f304
commit 01066c72b5

View File

@ -119,27 +119,29 @@ func (p *ProjectAPI) Post() {
return return
} }
user, err := dao.GetUser(models.User{ go func() {
UserID: p.userID, 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) if err != nil {
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) log.Errorf("failed to get user by ID %d: %v", p.userID, err)
} p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
accessLog := models.AccessLog{ accessLog := models.AccessLog{
Username: user.Username, Username: user.Username,
ProjectID: projectID, ProjectID: projectID,
RepoName: project.Name + "/", RepoName: project.Name + "/",
RepoTag: "N/A", RepoTag: "N/A",
GUID: "N/A", GUID: "N/A",
Operation: "create", Operation: "create",
OpTime: time.Now(), OpTime: time.Now(),
} }
if err = dao.AddAccessLog(accessLog); err != nil { if err = dao.AddAccessLog(accessLog); err != nil {
log.Errorf("failed to add access log: %v", err) log.Errorf("failed to add access log: %v", err)
p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) p.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
} }
}()
p.Redirect(http.StatusCreated, strconv.FormatInt(projectID, 10)) p.Redirect(http.StatusCreated, strconv.FormatInt(projectID, 10))
} }