mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate Plugin.DeleteAllForPlugin to Sync by default (#11597)
This commit is contained in:
committed by
Joram Wilander
parent
70fd0e0d6f
commit
e9b82bc1ce
@@ -103,9 +103,9 @@ func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
|
||||
if result := <-a.Srv.Store.Plugin().DeleteAllForPlugin(pluginId); result.Err != nil {
|
||||
mlog.Error("Failed to delete all plugin key values", mlog.String("plugin_id", pluginId), mlog.Err(result.Err))
|
||||
return result.Err
|
||||
if err := a.Srv.Store.Plugin().DeleteAllForPlugin(pluginId); err != nil {
|
||||
mlog.Error("Failed to delete all plugin key values", mlog.String("plugin_id", pluginId), mlog.Err(err))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -134,14 +134,11 @@ func (ps SqlPluginStore) Delete(pluginId, key string) store.StoreChannel {
|
||||
})
|
||||
}
|
||||
|
||||
func (ps SqlPluginStore) DeleteAllForPlugin(pluginId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := ps.GetMaster().Exec("DELETE FROM PluginKeyValueStore WHERE PluginId = :PluginId", map[string]interface{}{"PluginId": pluginId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlPluginStore.Delete", "store.sql_plugin_store.delete.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = true
|
||||
}
|
||||
})
|
||||
func (ps SqlPluginStore) DeleteAllForPlugin(pluginId string) *model.AppError {
|
||||
if _, err := ps.GetMaster().Exec("DELETE FROM PluginKeyValueStore WHERE PluginId = :PluginId", map[string]interface{}{"PluginId": pluginId}); err != nil {
|
||||
return model.NewAppError("SqlPluginStore.Delete", "store.sql_plugin_store.delete.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps SqlPluginStore) DeleteAllExpired() *model.AppError {
|
||||
|
||||
@@ -539,7 +539,7 @@ type PluginStore interface {
|
||||
CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, *model.AppError)
|
||||
Get(pluginId, key string) (*model.PluginKeyValue, *model.AppError)
|
||||
Delete(pluginId, key string) StoreChannel
|
||||
DeleteAllForPlugin(PluginId string) StoreChannel
|
||||
DeleteAllForPlugin(PluginId string) *model.AppError
|
||||
DeleteAllExpired() *model.AppError
|
||||
List(pluginId string, page, perPage int) ([]string, *model.AppError)
|
||||
}
|
||||
|
||||
@@ -69,15 +69,15 @@ func (_m *PluginStore) DeleteAllExpired() *model.AppError {
|
||||
}
|
||||
|
||||
// DeleteAllForPlugin provides a mock function with given fields: PluginId
|
||||
func (_m *PluginStore) DeleteAllForPlugin(PluginId string) store.StoreChannel {
|
||||
func (_m *PluginStore) DeleteAllForPlugin(PluginId string) *model.AppError {
|
||||
ret := _m.Called(PluginId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||
r0 = rf(PluginId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ func testPluginDeleteAll(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.Nil(t, err)
|
||||
|
||||
if result := <-ss.Plugin().DeleteAllForPlugin(pluginId); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
if err := ss.Plugin().DeleteAllForPlugin(pluginId); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := ss.Plugin().Get(pluginId, kv.Key); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user