1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-11 18:20:28 +09:00

Fix attach

This commit is contained in:
mcrakhman 2024-11-24 18:59:01 +01:00
parent 0705d1a6b8
commit c38a75e941
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -200,7 +200,7 @@ func (t *Tree) RemoveInvalidChange(id string) {
t.updateHeads()
}
func (t *Tree) add(c *Change) (attached bool) {
func (t *Tree) add(c *Change) bool {
if c == nil {
return false
}
@ -231,7 +231,7 @@ func (t *Tree) add(c *Change) (attached bool) {
} else if !remove {
t.unAttached[c.Id] = c
}
return
return attach
}
func (t *Tree) canAttachOrRemove(c *Change, addToWait bool) (attach, remove bool) {
@ -261,12 +261,12 @@ func (t *Tree) canAttachOrRemove(c *Change, addToWait bool) (attach, remove bool
return
}
// we should also have snapshot of attached change inside tree
sn, ok := t.attached[c.SnapshotId]
_, ok := t.attached[c.SnapshotId]
if !ok {
log.Error("snapshot not found in tree", zap.String("id", c.Id), zap.String("snapshot", c.SnapshotId))
return false, true
}
if !slices.Contains(prevSnapshots, sn.SnapshotId) {
if !slices.Contains(prevSnapshots, c.SnapshotId) {
log.Error("change has different snapshot than its prev ids", zap.String("id", c.Id), zap.String("snapshot", c.SnapshotId))
return false, true
}