From 44e3651adf17400a033956d225a52889132195e9 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 30 Aug 2022 12:20:20 +0200 Subject: [PATCH] Revert "Add workaround for SQLiteSession needing save after init" This reverts commit 8190a92aae3f44c92d59ea6600bfdb98c89d9a60. --- telethon/client/telegrambaseclient.py | 6 ------ telethon/sessions/sqlite.py | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/telethon/client/telegrambaseclient.py b/telethon/client/telegrambaseclient.py index c234f357..7f154a97 100644 --- a/telethon/client/telegrambaseclient.py +++ b/telethon/client/telegrambaseclient.py @@ -523,12 +523,6 @@ class TelegramBaseClient(abc.ABC): except OSError: print('Failed to connect') """ - # Workaround specific to SQLiteSession, which sometimes need to persist info after init. - # Since .save() is now async we can't do that in init. Instead we do it in the first connect. - if isinstance(self.session, SQLiteSession) and not self.session._init_saved: - await self.session.save() - self.session._init_saved = True - if not await self._sender.connect(self._connection( self.session.server_address, self.session.port, diff --git a/telethon/sessions/sqlite.py b/telethon/sessions/sqlite.py index f55a80f5..dff73df3 100644 --- a/telethon/sessions/sqlite.py +++ b/telethon/sessions/sqlite.py @@ -37,7 +37,6 @@ class SQLiteSession(MemorySession): super().__init__() self.filename = ':memory:' self.save_entities = True - self._init_saved = True if session_id: self.filename = session_id @@ -56,7 +55,7 @@ class SQLiteSession(MemorySession): self._upgrade_database(old=version) c.execute("delete from version") c.execute("insert into version values (?)", (CURRENT_VERSION,)) - self._init_saved = False + self.save() # These values will be saved c.execute('select * from sessions') @@ -110,7 +109,7 @@ class SQLiteSession(MemorySession): c.execute("insert into version values (?)", (CURRENT_VERSION,)) self._update_session_table() c.close() - self._init_saved = False + self.save() def clone(self, to_instance=None): cloned = super().clone(to_instance)