MM-15287: Migrate commandstore.save to sync by default (#10738)

* MM-15287: Migrate commandstore.save to sync by default

* MM-15287: Minor change to follow code consistency
Этот коммит содержится в:
Puneeth Reddy
2019-04-29 09:07:38 -07:00
коммит произвёл Jesús Espino
родитель c8920588a0
Коммит 13403b2cc1
5 изменённых файлов: 67 добавлений и 39 удалений

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

@@ -44,24 +44,21 @@ func (s SqlCommandStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_command_delete_at", "Commands", "DeleteAt")
}
func (s SqlCommandStore) Save(command *model.Command) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
if len(command.Id) > 0 {
result.Err = model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id, http.StatusBadRequest)
return
}
func (s SqlCommandStore) Save(command *model.Command) (*model.Command, *model.AppError) {
if len(command.Id) > 0 {
return nil, model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id, http.StatusBadRequest)
}
command.PreSave()
if result.Err = command.IsValid(); result.Err != nil {
return
}
command.PreSave()
if err := command.IsValid(); err != nil {
return nil, err
}
if err := s.GetMaster().Insert(command); err != nil {
result.Err = model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error(), http.StatusInternalServerError)
} else {
result.Data = command
}
})
if err := s.GetMaster().Insert(command); err != nil {
return nil, model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error(), http.StatusInternalServerError)
}
return command, nil
}
func (s SqlCommandStore) Get(id string) store.StoreChannel {