Browse Source

detect stale persisted cm list and update

pull/168/head
Rossen Georgiev 6 years ago
parent
commit
ffed0571f6
  1. 15
      steam/client/__init__.py

15
steam/client/__init__.py

@ -128,7 +128,20 @@ class SteamClient(CMClient, BuiltinBase):
if self.credential_location:
filepath = os.path.join(self.credential_location, 'cm_servers.json')
if not os.path.exists(filepath):
if os.path.exists(filepath):
try:
with open(filepath, 'r') as f:
data = json.load(f)
except ValueError:
self._LOG.error("Failed parsing %s", repr(filepath))
except IOError as e:
self._LOG.error("Failed reading %s (%s)", repr(filepath), str(e))
else:
if data.get('last_updated', 0) + 3600*24 > time():
return
self._LOG.debug("Persisted CM server list is stale")
data = {
'cell_id': self.cm_servers.cell_id,
'last_updated': self.cm_servers.last_updated,

Loading…
Cancel
Save