mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Validate recently added change just in case
This commit is contained in:
parent
16ef198c76
commit
f9a84f23f9
1 changed files with 9 additions and 1 deletions
|
@ -235,11 +235,19 @@ func (ot *objectTree) AddContentWithValidator(ctx context.Context, content Signa
|
|||
oldHeads = append(oldHeads, ot.tree.Heads()...)
|
||||
|
||||
objChange, rawChange, err := ot.changeBuilder.Build(payload)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// validating the change just in case to avoid possible bugs
|
||||
err = ot.validateTree([]*Change{objChange})
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error validating added change: %w", err)
|
||||
return
|
||||
}
|
||||
if content.IsSnapshot {
|
||||
// clearing tree, because we already saved everything in the last snapshot
|
||||
ot.tree = &Tree{}
|
||||
}
|
||||
|
||||
if validator != nil {
|
||||
err = validator(rawChange)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue