diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2021-11-02 16:47:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-02 16:47:39 +0000 |
commit | b99f594a93dda7645fabda4b81498ea4ad40bc97 (patch) | |
tree | 58ccb9c1a6fb75caf26b38946ba8f21e118e0030 /roomserver/storage/shared/storage.go | |
parent | 5b969d172b6dc900e89b77a630a8b1b72dff44a1 (diff) |
Fix #2028 (#2036)
Diffstat (limited to 'roomserver/storage/shared/storage.go')
-rw-r--r-- | roomserver/storage/shared/storage.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index b4fc15f1..3685332f 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -165,14 +165,21 @@ func (d *Database) AddState( if berr != nil { return 0, fmt.Errorf("d.StateBlockTable.BulkSelectStateBlockEntries: %w", berr) } + var found bool for i := len(state) - 1; i >= 0; i-- { + found = false for _, events := range blocks { for _, event := range events { if state[i].EventNID == event { - state = append(state[:i], state[i+1:]...) + found = true + break } } } + if found { + state = append(state[:i], state[i+1:]...) + i-- + } } } err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error { |