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

Change deletion logic in headsync and objectsync

This commit is contained in:
mcrakhman 2023-02-23 23:58:09 +01:00 committed by Mikhail Iudin
parent 73b27c7dac
commit a0aa02bb8a
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
4 changed files with 28 additions and 13 deletions

View file

@ -9,6 +9,7 @@ import (
type SpaceIdsProvider interface {
AllIds() []string
RemoveObjects(ids []string)
}
type SpaceDeleter interface {
@ -60,13 +61,17 @@ func (d *deletionManager) UpdateState(state *settingsstate.State) (err error) {
if ok {
spaceDeleter.DeleteSpace(d.spaceId)
}
d.onSpaceDelete()
if d.isResponsible {
allIds := slice.DiscardFromSlice(d.provider.AllIds(), func(s string) bool {
return s == d.settingsId
allIds := slice.DiscardFromSlice(d.provider.AllIds(), func(id string) bool {
return id == d.settingsId
})
err = d.deletionState.Add(allIds)
if err != nil {
return
}
d.provider.RemoveObjects(allIds)
}
d.onSpaceDelete()
}
return
}