mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
edsm: Add a paranoia check for changed gameversion
* In theory we would always see `Fileheader` and clear `pending[]`, but let's be extra paranoid and also clear it if there's a gameversion/build difference between the prior event and the current one.
This commit is contained in:
parent
1ec1253b48
commit
a581d889fe
@ -644,6 +644,8 @@ def worker() -> None: # noqa: CCR001 C901 # Cant be broken up currently
|
||||
pending: List[Mapping[str, Any]] = [] # Unsent events
|
||||
closing = False
|
||||
cmdr: str = ""
|
||||
last_game_version = ""
|
||||
last_game_build = ""
|
||||
entry: Mapping[str, Any] = {}
|
||||
|
||||
while not this.discarded_events:
|
||||
@ -692,6 +694,20 @@ def worker() -> None: # noqa: CCR001 C901 # Cant be broken up currently
|
||||
logger.trace_if(
|
||||
CMDR_EVENTS, f'({cmdr=}, {entry["event"]=}): not in discarded_events, appending to pending')
|
||||
|
||||
# Discard the pending list if it's a new Journal file OR
|
||||
# if the gameversion has changed. We claim a single
|
||||
# gameversion for an entire batch of events so can't mix
|
||||
# them.
|
||||
# The specific gameversion check caters for scenarios where
|
||||
# we took some time in the last POST, had new events queued
|
||||
# in the meantime *and* the game client crashed *and* was
|
||||
# changed to a different gameversion.
|
||||
if (
|
||||
entry['event'].lower() == 'fileheader'
|
||||
or last_game_version != game_version or last_game_build != game_build
|
||||
):
|
||||
pending = []
|
||||
|
||||
pending.append(entry)
|
||||
|
||||
# drop events if required by killswitch
|
||||
@ -823,6 +839,9 @@ def worker() -> None: # noqa: CCR001 C901 # Cant be broken up currently
|
||||
logger.debug('closing, so returning.')
|
||||
return
|
||||
|
||||
last_game_version = game_version
|
||||
last_game_build = game_build
|
||||
|
||||
logger.debug('Done.')
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user