Add target serialization to first state
This commit is contained in:
parent
5f2809c394
commit
7ff4e8faa0
@ -32,8 +32,8 @@ class SyncFsItem:
|
|||||||
|
|
||||||
logg.debug('get key {}'.format(self.state_key))
|
logg.debug('get key {}'.format(self.state_key))
|
||||||
v = self.sync_state.get(self.state_key)
|
v = self.sync_state.get(self.state_key)
|
||||||
self.cursor = int.from_bytes(v[:4], 'big')
|
|
||||||
self.tx_cursor = int.from_bytes(v[4:], 'big')
|
(self.cursor, self.tx_cursor, self.target) = sync_state_deserialize(v)
|
||||||
|
|
||||||
if self.filter_state.state(self.state_key) & self.filter_state.from_name('LOCK') and not ignore_invalid:
|
if self.filter_state.state(self.state_key) & self.filter_state.from_name('LOCK') and not ignore_invalid:
|
||||||
raise LockError(s)
|
raise LockError(s)
|
||||||
@ -244,17 +244,13 @@ class SyncFsStore:
|
|||||||
self.__load(target)
|
self.__load(target)
|
||||||
|
|
||||||
if self.first:
|
if self.first:
|
||||||
block_number = offset
|
state_bytes = sync_state_serialize(offset, 0, target)
|
||||||
state_bytes = block_number.to_bytes(4, 'big')
|
block_number_str = str(offset)
|
||||||
tx_index = 0
|
|
||||||
state_bytes += tx_index.to_bytes(4, 'big')
|
|
||||||
block_number_str = str(block_number)
|
|
||||||
self.state.put(block_number_str, state_bytes)
|
self.state.put(block_number_str, state_bytes)
|
||||||
self.filter_state.put(block_number_str)
|
self.filter_state.put(block_number_str)
|
||||||
o = SyncFsItem(block_number, target, self.state, self.filter_state)
|
o = SyncFsItem(offset, target, self.state, self.filter_state)
|
||||||
self.items[block_number] = o
|
self.items[offset] = o
|
||||||
self.item_keys.append(block_number)
|
self.item_keys.append(offset)
|
||||||
logg.debug('added first {}'.format(o))
|
|
||||||
elif offset > 0:
|
elif offset > 0:
|
||||||
logg.warning('block number argument {} for start ignored for already initiated sync {}'.format(offset, self.session_id))
|
logg.warning('block number argument {} for start ignored for already initiated sync {}'.format(offset, self.session_id))
|
||||||
self.started = True
|
self.started = True
|
||||||
|
@ -193,13 +193,11 @@ class TestFs(unittest.TestCase):
|
|||||||
session = SyncSession(store)
|
session = SyncSession(store)
|
||||||
|
|
||||||
session.start()
|
session.start()
|
||||||
logg.debug('list {} {} {}'.format(store.state.list(store.state.SYNC), store.state.list(store.state.DONE), store.state.list(store.state.NEW)))
|
|
||||||
o = session.get(0)
|
o = session.get(0)
|
||||||
o.next(advance_block=True)
|
o.next(advance_block=True)
|
||||||
o.next(advance_block=True)
|
o.next(advance_block=True)
|
||||||
session.stop(o)
|
session.stop(o)
|
||||||
|
|
||||||
logg.debug('list {} {} {}'.format(store.state.list(store.state.SYNC), store.state.list(store.state.DONE), store.state.list(store.state.NEW)))
|
|
||||||
store = SyncFsStore(self.path, session_id='foo')
|
store = SyncFsStore(self.path, session_id='foo')
|
||||||
store.start()
|
store.start()
|
||||||
o = store.get(2)
|
o = store.get(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user