1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Fix tree reduce

This commit is contained in:
mcrakhman 2025-01-04 12:02:04 +01:00
parent 4b4287ebdd
commit 43a8bf9071
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -76,12 +76,13 @@ func (t *Tree) reduceTree() (res bool) {
// checking where paths from other heads intersect path
maxIdx := 0
for i := 1; i < len(t.headIds); i++ {
cur, ok := t.attached[t.attached[t.headIds[i]].SnapshotId]
headSnapshot := t.attached[t.headIds[i]].SnapshotId
cur, ok := t.attached[headSnapshot]
if !ok {
log.Error("snapshot not found in tree", zap.String("snapshotId", t.attached[t.headIds[i]].SnapshotId))
return false
}
for cur.Id != t.root.Id {
for {
if cur.visited {
// TODO: we may use counters here but it is not necessary
idx := slices.IndexFunc(path, func(c *Change) bool {