From aa2583a02702abef9bb41150c80538439e57f4b1 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Wed, 19 Aug 2015 16:31:53 -0700 Subject: Adding enviroment files --- .agignore | 3 +++ .ctags | 19 +++++++++++++++++++ .gitignore | 4 ++++ 3 files changed, 26 insertions(+) create mode 100644 .agignore create mode 100644 .ctags diff --git a/.agignore b/.agignore new file mode 100644 index 000000000..ca1b2cf52 --- /dev/null +++ b/.agignore @@ -0,0 +1,3 @@ +tags +Godeps/* +static/js/* diff --git a/.ctags b/.ctags new file mode 100644 index 000000000..35fdcba9c --- /dev/null +++ b/.ctags @@ -0,0 +1,19 @@ +--recurse=yes +--exclude=.git +--exclude=Godeps +--exclude=node_modules +--exclude=static + +--langdef=Go +--langmap=Go:.go +--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/ +--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/ +--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/ + +--langdef=JSX +--langmap=jsx:.jsx +--regex-jsx=/^[ \t]*import[ \t]+([^;]+)/\1/r,import,imports/ +--regex-jsx=/^[ \t]*([a-z]+[ \t]+)*function[ \t]+([A-Za-z0-9_]+[ \t]*[^{;]*)/\2/f,function,functions/ +--regex-jsx=/^[ \t]*([a-z]+[ \t]+)*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/c,class,classes/ +--regex-jsx=/^[ \t]*([a-z]+[ \t]+)*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/i,interface,interfaces/ +--regex-jsx=/^[ \t]*([a-z]+[ \t]+)*mixin[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/m,mixin,mixins/ diff --git a/.gitignore b/.gitignore index 97de7eea5..79761adac 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ web/sass-files/sass/.sass-cache/ # Default local file storage data/* api/data/* + +.agignore +.ctags +tags -- cgit v1.2.3-1-g7c22 From 3f0ec24dc1c18a550913beba8e742e0dbb4c7b42 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 14:20:39 -0700 Subject: Fixing build --- api/context.go | 18 +++++++++++------- model/client.go | 2 ++ store/store.go | 4 ++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/api/context.go b/api/context.go index e3f279e90..e6439e977 100644 --- a/api/context.go +++ b/api/context.go @@ -195,18 +195,22 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (c *Context) LogAudit(extraInfo string) { - audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + go func() { + audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + <-Srv.Store.Audit().Save(audit) + }() } func (c *Context) LogAuditWithUserId(userId, extraInfo string) { - if len(c.Session.UserId) > 0 { - extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) - } + go func() { + if len(c.Session.UserId) > 0 { + extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) + } - audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - Srv.Store.Audit().Save(audit) + audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + <-Srv.Store.Audit().Save(audit) + }() } func (c *Context) LogError(err *model.AppError) { diff --git a/model/client.go b/model/client.go index 6fcfa5043..17e2466df 100644 --- a/model/client.go +++ b/model/client.go @@ -5,6 +5,7 @@ package model import ( "bytes" + l4g "code.google.com/p/log4go" "fmt" "io/ioutil" "net/http" @@ -93,6 +94,7 @@ func getCookie(name string, resp *http.Response) *http.Cookie { func (c *Client) Must(result *Result, err *AppError) *Result { if err != nil { + l4g.Close() time.Sleep(time.Second) panic(err) } diff --git a/store/store.go b/store/store.go index 617ea7f2b..8dbf12b55 100644 --- a/store/store.go +++ b/store/store.go @@ -4,7 +4,9 @@ package store import ( + l4g "code.google.com/p/log4go" "github.com/mattermost/platform/model" + "time" ) type StoreResult struct { @@ -17,6 +19,8 @@ type StoreChannel chan StoreResult func Must(sc StoreChannel) interface{} { r := <-sc if r.Err != nil { + l4g.Close() + time.Sleep(time.Second) panic(r.Err) } -- cgit v1.2.3-1-g7c22 From 1b4135ab0da3c1635fae23f8f64247eb78866819 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 14:40:25 -0700 Subject: Fixing bug --- store/sql_channel_store.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index cf34f2847..25cd46088 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -153,8 +153,10 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { channel.ExtraUpdated() - if count, err := s.GetMaster().Update(channel); err != nil || count != 1 { + if count, err := s.GetMaster().Update(channel); err != nil { result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id+", "+err.Error()) + } else if count == 0 { + result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id) } storeChannel <- result -- cgit v1.2.3-1-g7c22 From 42822df5b3451114e71aff946d755f6dd3cfd1c9 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 14:48:04 -0700 Subject: Fixing race condition --- store/sql_channel_store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 25cd46088..a7577e645 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -4,6 +4,7 @@ package store import ( + "fmt" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -155,8 +156,8 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel { if count, err := s.GetMaster().Update(channel); err != nil { result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id+", "+err.Error()) - } else if count == 0 { - result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", "id="+channel.Id) + } else if count != 1 { + result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "Problem updating members last updated time", fmt.Sprintf("id=%v, count=%v", channel.Id, count)) } storeChannel <- result -- cgit v1.2.3-1-g7c22 From 09b0f61194238715875b545dc6cfb30d8f69a3dd Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 14:48:51 -0700 Subject: Removing my enviroment --- .agignore | 3 --- .ctags | 19 ------------------- 2 files changed, 22 deletions(-) delete mode 100644 .agignore delete mode 100644 .ctags diff --git a/.agignore b/.agignore deleted file mode 100644 index ca1b2cf52..000000000 --- a/.agignore +++ /dev/null @@ -1,3 +0,0 @@ -tags -Godeps/* -static/js/* diff --git a/.ctags b/.ctags deleted file mode 100644 index 35fdcba9c..000000000 --- a/.ctags +++ /dev/null @@ -1,19 +0,0 @@ ---recurse=yes ---exclude=.git ---exclude=Godeps ---exclude=node_modules ---exclude=static - ---langdef=Go ---langmap=Go:.go ---regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/ ---regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/ ---regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/ - ---langdef=JSX ---langmap=jsx:.jsx ---regex-jsx=/^[ \t]*import[ \t]+([^;]+)/\1/r,import,imports/ ---regex-jsx=/^[ \t]*([a-z]+[ \t]+)*function[ \t]+([A-Za-z0-9_]+[ \t]*[^{;]*)/\2/f,function,functions/ ---regex-jsx=/^[ \t]*([a-z]+[ \t]+)*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/c,class,classes/ ---regex-jsx=/^[ \t]*([a-z]+[ \t]+)*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/i,interface,interfaces/ ---regex-jsx=/^[ \t]*([a-z]+[ \t]+)*mixin[ \t]+([A-Za-z0-9_]+)[ \t]*([^)])/\2/m,mixin,mixins/ -- cgit v1.2.3-1-g7c22 From e4b66c3ff41bcac47f026151a7cb1b19b1217672 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 20 Aug 2015 15:04:37 -0700 Subject: Fixing audit log to wait for confirm --- api/context.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/context.go b/api/context.go index e6439e977..8babf85f2 100644 --- a/api/context.go +++ b/api/context.go @@ -195,22 +195,22 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (c *Context) LogAudit(extraInfo string) { - go func() { - audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - <-Srv.Store.Audit().Save(audit) - }() + audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogAuditWithUserId(userId, extraInfo string) { - go func() { - if len(c.Session.UserId) > 0 { - extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) - } + if len(c.Session.UserId) > 0 { + extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.Session.UserId) + } - audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} - <-Srv.Store.Audit().Save(audit) - }() + audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.AltId} + if r := <-Srv.Store.Audit().Save(audit); r.Err != nil { + c.LogError(r.Err) + } } func (c *Context) LogError(err *model.AppError) { -- cgit v1.2.3-1-g7c22