mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-04 02:53:40 +00:00
Fix empty state snapshots
This commit is contained in:
parent
a799847070
commit
b7cf702a14
4 changed files with 5 additions and 9 deletions
|
@ -463,7 +463,7 @@ func (v *StateResolution) CalculateAndStoreStateBeforeEvent(
|
|||
// Load the state at the prev events.
|
||||
prevStates, err := v.db.StateAtEventIDs(ctx, event.PrevEventIDs())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, fmt.Errorf("v.db.StateAtEventIDs: %w", err)
|
||||
}
|
||||
|
||||
// The state before this event will be the state after the events that came before it.
|
||||
|
|
|
@ -99,6 +99,7 @@ func (s *stateStatements) BulkSelectState(
|
|||
if err = rows.Scan(&stateNID, &eventNIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
results[types.StateSnapshotNID(stateNID)] = []types.EventNID{}
|
||||
for _, id := range eventNIDs {
|
||||
results[types.StateSnapshotNID(stateNID)] = append(
|
||||
results[types.StateSnapshotNID(stateNID)],
|
||||
|
|
|
@ -215,7 +215,7 @@ func (d *Database) StateEntries(
|
|||
) ([]types.StateEntry, error) {
|
||||
nids, err := d.StateTable.BulkSelectState(ctx, []types.StateSnapshotNID{stateSnapshotNID})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("d.StateTable.BulkSelectState: %w", err)
|
||||
return nil, fmt.Errorf("d.StateTable.BulkSelectState: %w (ID %d)", err, stateSnapshotNID)
|
||||
}
|
||||
state, ok := nids[stateSnapshotNID]
|
||||
if !ok {
|
||||
|
|
|
@ -111,16 +111,11 @@ func (s *stateStatements) BulkSelectState(
|
|||
if err = rows.Scan(&stateNID, &eventNIDJSON); err != nil {
|
||||
return nil, fmt.Errorf("rows.Scan: %w", err)
|
||||
}
|
||||
var eventNIDs []int64
|
||||
var eventNIDs []types.EventNID
|
||||
if err = json.Unmarshal(eventNIDJSON, &eventNIDs); err != nil {
|
||||
return nil, fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
for _, id := range eventNIDs {
|
||||
results[types.StateSnapshotNID(stateNID)] = append(
|
||||
results[types.StateSnapshotNID(stateNID)],
|
||||
types.EventNID(id),
|
||||
)
|
||||
}
|
||||
results[types.StateSnapshotNID(stateNID)] = eventNIDs
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, fmt.Errorf("rows.Err: %w", err)
|
||||
|
|
Loading…
Reference in a new issue