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

write space hash on open

This commit is contained in:
Sergey Cherepanov 2023-01-13 19:51:29 +03:00 committed by Mikhail Iudin
parent ccfcc2f399
commit 11d50d087a
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
3 changed files with 8 additions and 2 deletions

View file

@ -23,7 +23,7 @@ type TreeHeads struct {
type HeadSync interface {
Init(objectIds []string, deletionState deletionstate.DeletionState)
UpdateHeads(id string, heads []string)
HandleRangeRequest(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error)
RemoveObjects(ids []string)
@ -126,6 +126,9 @@ func (d *headSync) fillDiff(objectIds []string) {
})
}
d.diff.Set(els...)
if err := d.storage.WriteSpaceHash(d.diff.Hash()); err != nil {
d.log.Error("can't write space hash", zap.Error(err))
}
}
func concatStrings(strs []string) string {

View file

@ -46,6 +46,9 @@ func TestDiffService(t *testing.T) {
Id: initId,
Head: "h1h2",
})
hash := "123"
diffMock.EXPECT().Hash().Return(hash)
storageMock.EXPECT().WriteSpaceHash(hash)
pSyncMock.EXPECT().Run()
service.Init([]string{initId}, delState)
})

View file

@ -37,7 +37,7 @@ type SpaceStorage interface {
TreeRoot(id string) (*treechangeproto.RawTreeChangeWithId, error)
TreeStorage(id string) (treestorage.TreeStorage, error)
CreateTreeStorage(payload treestorage.TreeStorageCreatePayload) (treestorage.TreeStorage, error)
WriteSpaceHash(head string) error
WriteSpaceHash(hash string) error
ReadSpaceHash() (hash string, err error)
Close() error