Migrate Plugin.DeleteAllExpired to Sync by default (#11583)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
25a2e7e981
Коммит
eb0268f108
@@ -116,9 +116,9 @@ func (a *App) DeleteAllExpiredPluginKeys() *model.AppError {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Plugin().DeleteAllExpired(); result.Err != nil {
|
if err := a.Srv.Store.Plugin().DeleteAllExpired(); err != nil {
|
||||||
mlog.Error("Failed to delete all expired plugin key values", mlog.Err(result.Err))
|
mlog.Error("Failed to delete all expired plugin key values", mlog.Err(err))
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -144,15 +144,12 @@ func (ps SqlPluginStore) DeleteAllForPlugin(pluginId string) store.StoreChannel
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps SqlPluginStore) DeleteAllExpired() store.StoreChannel {
|
func (ps SqlPluginStore) DeleteAllExpired() *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
currentTime := model.GetMillis()
|
||||||
currentTime := model.GetMillis()
|
if _, err := ps.GetMaster().Exec("DELETE FROM PluginKeyValueStore WHERE ExpireAt != 0 AND ExpireAt < :CurrentTime", map[string]interface{}{"CurrentTime": currentTime}); err != nil {
|
||||||
if _, err := ps.GetMaster().Exec("DELETE FROM PluginKeyValueStore WHERE ExpireAt != 0 AND ExpireAt < :CurrentTime", map[string]interface{}{"CurrentTime": currentTime}); err != nil {
|
return model.NewAppError("SqlPluginStore.Delete", "store.sql_plugin_store.delete.app_error", nil, fmt.Sprintf("current_time=%v, err=%v", currentTime, err.Error()), http.StatusInternalServerError)
|
||||||
result.Err = model.NewAppError("SqlPluginStore.Delete", "store.sql_plugin_store.delete.app_error", nil, fmt.Sprintf("current_time=%v, err=%v", currentTime, err.Error()), http.StatusInternalServerError)
|
}
|
||||||
} else {
|
return nil
|
||||||
result.Data = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) ([]string, *model.AppError) {
|
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) ([]string, *model.AppError) {
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ type PluginStore interface {
|
|||||||
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) StoreChannel
|
||||||
DeleteAllExpired() StoreChannel
|
DeleteAllExpired() *model.AppError
|
||||||
List(pluginId string, page, perPage int) ([]string, *model.AppError)
|
List(pluginId string, page, perPage int) ([]string, *model.AppError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,15 +53,15 @@ func (_m *PluginStore) Delete(pluginId string, key string) store.StoreChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAllExpired provides a mock function with given fields:
|
// DeleteAllExpired provides a mock function with given fields:
|
||||||
func (_m *PluginStore) DeleteAllExpired() store.StoreChannel {
|
func (_m *PluginStore) DeleteAllExpired() *model.AppError {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
|
||||||
r0 = rf()
|
r0 = rf()
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,8 +168,8 @@ func testPluginDeleteExpired(t *testing.T, ss store.Store) {
|
|||||||
})
|
})
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
if result := <-ss.Plugin().DeleteAllExpired(); result.Err != nil {
|
if err := ss.Plugin().DeleteAllExpired(); 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