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:
Lonami Exo 2021-09-19 18:02:08 +02:00
parent 016347474a
commit 3f13357d0f

View File

@ -202,17 +202,22 @@ class SQLiteSession(Session):
return res return res
async def set_state(self, state: SessionState): async def set_state(self, state: SessionState):
self._execute( c = self._cursor()
'insert or replace into session values (?,?,?,?,?,?,?,?)', try:
state.user_id, self._execute('delete from session')
state.dc_id, self._execute(
int(state.bot), 'insert into session values (?,?,?,?,?,?,?,?)',
state.pts, state.user_id,
state.qts, state.dc_id,
state.date, int(state.bot),
state.seq, state.pts,
state.takeout_id, state.qts,
) state.date,
state.seq,
state.takeout_id,
)
finally:
c.close()
async def get_state(self) -> Optional[SessionState]: async def get_state(self) -> Optional[SessionState]:
row = self._execute('select * from session') row = self._execute('select * from session')