etebase-docs icon indicating copy to clipboard operation
etebase-docs copied to clipboard

Question concerning the etebase api

Open FloLan1 opened this issue 1 year ago • 1 comments

I'm a hobby programmer working on an app. Playing around with the etebase api I stumbled over a problem I'm not quite sure how to solve: The item manager allows to use a stoken to receive a list of items that have changed since the last sync. But this list includes items that were changed by the client itself. Is there a way to filter for the items that were changed by other users? SyncEtebase

FloLan1 avatar Dec 06 '23 23:12 FloLan1

Update from my side: The items have a property called etag that changes when content is reassigned. So this property can be used for the local bookkeeping. Unfortunately, changing the meta data does not affect the etag. The following python sniped shows the behavior:

...

item.content = b'0'
item.meta['type'] = '0'

print('etag   before edit:               '+item.etag)
print('stoken before edit:               '+collection.stoken)
print('')
item.content = b'1'
print('etag   after first content edit:  '+item.etag)
print('stoken after first content edit:  '+collection.stoken)
print('')
item.content = b'1'
print('etag   after second content edit: '+item.etag)
print('stoken after second content edit: '+collection.stoken)
print('')
item.meta['type'] = '1'
print('etag   after meta edit:           '+item.etag)
print('stoken after meta edit:           '+collection.stoken)
print('')
itemmgr.transaction([item])
print('etag   after transaction:         '+item.etag)
print('stoken after transaction:         '+collection.stoken)
print('')

response = itemmgr.list(FetchOptions().stoken(collection.stoken))
item = list(response.data)[0]
print('etag   after sync:                '+item.etag)
print('stoken after sync:                '+response.stoken)

...

The output is:

etag   before edit:               ubBCvjMFnRZhfjU_4SFskQ
stoken before edit:               Afk3vCEr1McaLFs9OtsAy3olvylMRt8K   

etag   after first content edit:  rhL5g4m1XktuC-hlQ3RnnQ
stoken after first content edit:  Afk3vCEr1McaLFs9OtsAy3olvylMRt8K   

etag   after second content edit: AA6anSED49zs7DrNdJ1Rhw
stoken after second content edit: Afk3vCEr1McaLFs9OtsAy3olvylMRt8K   

etag   after meta edit:           AA6anSED49zs7DrNdJ1Rhw
stoken after meta edit:           Afk3vCEr1McaLFs9OtsAy3olvylMRt8K   

etag   after transaction:         AA6anSED49zs7DrNdJ1Rhw
stoken after transaction:         Afk3vCEr1McaLFs9OtsAy3olvylMRt8K   

etag   after sync:                AA6anSED49zs7DrNdJ1Rhw
stoken after sync:                yFPfvWmWGTIYbdjz3b7_NdYOXZvauqim 

FloLan1 avatar Dec 07 '23 21:12 FloLan1