Migrate Plugin.DeleteAllForPlugin to Sync by default (#11597)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
70fd0e0d6f
Коммит
e9b82bc1ce
@@ -103,9 +103,9 @@ func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
|
func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
|
||||||
if result := <-a.Srv.Store.Plugin().DeleteAllForPlugin(pluginId); result.Err != nil {
|
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(result.Err))
|
mlog.Error("Failed to delete all plugin key values", mlog.String("plugin_id", pluginId), mlog.Err(err))
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -134,14 +134,11 @@ func (ps SqlPluginStore) Delete(pluginId, key string) store.StoreChannel {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps SqlPluginStore) DeleteAllForPlugin(pluginId string) store.StoreChannel {
|
func (ps SqlPluginStore) DeleteAllForPlugin(pluginId string) *model.AppError {
|
||||||
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 {
|
||||||
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)
|
||||||
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 {
|
return nil
|
||||||
result.Data = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps SqlPluginStore) DeleteAllExpired() *model.AppError {
|
func (ps SqlPluginStore) DeleteAllExpired() *model.AppError {
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ type PluginStore interface {
|
|||||||
CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, *model.AppError)
|
CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, *model.AppError)
|
||||||
Get(pluginId, key string) (*model.PluginKeyValue, *model.AppError)
|
Get(pluginId, key string) (*model.PluginKeyValue, *model.AppError)
|
||||||
Delete(pluginId, key string) StoreChannel
|
Delete(pluginId, key string) StoreChannel
|
||||||
DeleteAllForPlugin(PluginId string) StoreChannel
|
DeleteAllForPlugin(PluginId string) *model.AppError
|
||||||
DeleteAllExpired() *model.AppError
|
DeleteAllExpired() *model.AppError
|
||||||
List(pluginId string, page, perPage int) ([]string, *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
|
// 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)
|
ret := _m.Called(PluginId)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||||
r0 = rf(PluginId)
|
r0 = rf(PluginId)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
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)
|
require.Nil(t, err)
|
||||||
|
|
||||||
if result := <-ss.Plugin().DeleteAllForPlugin(pluginId); result.Err != nil {
|
if err := ss.Plugin().DeleteAllForPlugin(pluginId); err != nil {
|
||||||
t.Fatal(result.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := ss.Plugin().Get(pluginId, kv.Key); err == nil {
|
if _, err := ss.Plugin().Get(pluginId, kv.Key); err == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user