WIP more deletion checks

This commit is contained in:
mcrakhman authored and Mikhail Iudin committed 2022-11-12 17:49:25 +01:00
1 parent 676976e7d3
commit a5fe46e50e
6 files changed
+63 -22

No files matched your search

@@ -69,10 +69,7 @@ func (d *diffService) HandleRangeRequest(ctx context.Context, req *spacesyncprot
}
func (d *diffService) UpdateHeads(id string, heads []string) {
d.diff.Set(ldiff.Element{
Id: id,
Head: concatStrings(heads),
})
d.syncer.UpdateHeads(id, heads)
}
func (d *diffService) AllIds() []string {
@@ -80,9 +77,6 @@ func (d *diffService) AllIds() []string {
}
func (d *diffService) RemoveObjects(ids []string) {
for _, id := range ids {
d.diff.RemoveId(id)
}
d.syncer.RemoveObjects(ids)
}
@@ -18,6 +18,7 @@ import (
type DiffSyncer interface {
Sync(ctx context.Context) error
RemoveObjects(ids []string)
UpdateHeads(id string, heads []string)
}
func newDiffSyncer(
@@ -56,10 +57,23 @@ func (d *diffSyncer) RemoveObjects(ids []string) {
d.Lock()
defer d.Unlock()
for _, id := range ids {
d.diff.RemoveId(id)
d.removedIds[id] = struct{}{}
}
}
func (d *diffSyncer) UpdateHeads(id string, heads []string) {
d.Lock()
defer d.Unlock()
if _, exists := d.removedIds[id]; exists {
return
}
d.diff.Set(ldiff.Element{
Id: id,
Head: concatStrings(heads),
})
}
func (d *diffSyncer) Sync(ctx context.Context) error {
st := time.Now()
// diffing with responsible peers according to configuration