mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-04-01 15:54:19 +03:00
Fix SQLiteSession.set_state did not always clear old state
For instance, when we stored a user_id of 0 because we did not login yet.
This commit is contained in:
parent
016347474a
commit
3f13357d0f
|
@ -202,17 +202,22 @@ class SQLiteSession(Session):
|
|||
return res
|
||||
|
||||
async def set_state(self, state: SessionState):
|
||||
self._execute(
|
||||
'insert or replace into session values (?,?,?,?,?,?,?,?)',
|
||||
state.user_id,
|
||||
state.dc_id,
|
||||
int(state.bot),
|
||||
state.pts,
|
||||
state.qts,
|
||||
state.date,
|
||||
state.seq,
|
||||
state.takeout_id,
|
||||
)
|
||||
c = self._cursor()
|
||||
try:
|
||||
self._execute('delete from session')
|
||||
self._execute(
|
||||
'insert into session values (?,?,?,?,?,?,?,?)',
|
||||
state.user_id,
|
||||
state.dc_id,
|
||||
int(state.bot),
|
||||
state.pts,
|
||||
state.qts,
|
||||
state.date,
|
||||
state.seq,
|
||||
state.takeout_id,
|
||||
)
|
||||
finally:
|
||||
c.close()
|
||||
|
||||
async def get_state(self) -> Optional[SessionState]:
|
||||
row = self._execute('select * from session')
|
||||
|
|
Loading…
Reference in New Issue
Block a user