MM-15294: migrate commandstore.Update to sync by default (#10745)

* MM-15294: migrate commandstore.Update to sync by default

* minor change for code consistency
Этот коммит содержится в:
Puneeth Reddy
2019-04-29 07:22:44 -07:00
коммит произвёл Lev
родитель dec3c8facb
Коммит 5b70962f71
5 изменённых файлов: 33 добавлений и 35 удалений

Просмотреть файл

@@ -132,20 +132,18 @@ func (s SqlCommandStore) PermanentDeleteByUser(userId string) *model.AppError {
return nil
}
func (s SqlCommandStore) Update(cmd *model.Command) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
cmd.UpdateAt = model.GetMillis()
func (s SqlCommandStore) Update(cmd *model.Command) (*model.Command, *model.AppError) {
cmd.UpdateAt = model.GetMillis()
if result.Err = cmd.IsValid(); result.Err != nil {
return
}
if err := cmd.IsValid(); err != nil {
return nil, err
}
if _, err := s.GetMaster().Update(cmd); err != nil {
result.Err = model.NewAppError("SqlCommandStore.Update", "store.sql_command.save.update.app_error", nil, "id="+cmd.Id+", "+err.Error(), http.StatusInternalServerError)
} else {
result.Data = cmd
}
})
if _, err := s.GetMaster().Update(cmd); err != nil {
return nil, model.NewAppError("SqlCommandStore.Update", "store.sql_command.save.update.app_error", nil, "id="+cmd.Id+", "+err.Error(), http.StatusInternalServerError)
}
return cmd, nil
}
func (s SqlCommandStore) AnalyticsCommandCount(teamId string) store.StoreChannel {