From 151e1623d3f0ed71951a73169849d6fbbeaad162 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 14 Sep 2017 11:44:42 +0200 Subject: [PATCH] Stop saving the session ID, sequence and time offset After some discussion, storing the session ID is not needed at all. It can always start off as a new random 8-byte-long number, also restarting the sequence number at 0. This should prevent some seqno too low errors. Also, saving the time offset could cause more trouble than fixing them, so that has also been removed. --- telethon/tl/session.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/telethon/tl/session.py b/telethon/tl/session.py index 0897012f..efaca3d7 100644 --- a/telethon/tl/session.py +++ b/telethon/tl/session.py @@ -66,11 +66,8 @@ class Session: if self.session_user_id: with open('{}.session'.format(self.session_user_id), 'w') as file: json.dump({ - 'id': self.id, 'port': self.port, 'salt': self.salt, - 'sequence': self._sequence, - 'time_offset': self.time_offset, 'server_address': self.server_address, 'auth_key_data': b64encode(self.auth_key.key).decode('ascii') @@ -109,11 +106,8 @@ class Session: try: with open(path, 'r') as file: data = json.load(file) - result.id = data['id'] result.port = data['port'] result.salt = data['salt'] - result._sequence = data['sequence'] - result.time_offset = data['time_offset'] result.server_address = data['server_address'] # FIXME We need to import the AuthKey here or otherwise @@ -128,7 +122,7 @@ class Session: return result - def generate_sequence(self, confirmed): + def generate_sequence(self, content_related): """Thread safe method to generates the next sequence number, based on whether it was confirmed yet or not. @@ -136,7 +130,7 @@ class Session: will be increased by one too """ with self._lock: - if confirmed: + if content_related: result = self._sequence * 2 + 1 self._sequence += 1 return result