Clearer branching, fix missing list clear

This commit is contained in:
Andrew Morgan 2019-03-04 14:36:52 +00:00
parent 0bc50fb60a
commit 9f7cdf3da1

View File

@ -488,16 +488,23 @@ class ServerReplicationStreamProtocol(BaseReplicationStreamProtocol):
# process all previous updates in the batch as if they had the # process all previous updates in the batch as if they had the
# final token. # final token.
if not token or len(batch_updates) > 0: if not token or len(batch_updates) > 0:
batch_updates.append(update) if token is None:
if token and not token > current_token: # Store this update as part of the batch
batch_updates.append(update)
elif current_token <= current_token:
# This batch is older than current_token, dismiss # This batch is older than current_token, dismiss
batch_updates = [] batch_updates = []
continue else:
if token: # Append final update of this batch before sending
batch_updates.append(update)
# Send all updates that are part of this batch with the # Send all updates that are part of this batch with the
# found token # found token
for update in batch_updates: for update in batch_updates:
self.send_command(RdataCommand(stream_name, token, update)) self.send_command(RdataCommand(stream_name, token, update))
# Clear saved batch updates
batch_updates = []
else: else:
# Only send updates newer than the current token # Only send updates newer than the current token
if token > current_token: if token > current_token: