mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 12:53:44 +03:00
Fix saving update state in the SqliteSession
This commit is contained in:
parent
9ef40102eb
commit
b71511cd63
|
@ -1,3 +1,4 @@
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -6,7 +7,6 @@ from os.path import isfile as file_exists
|
||||||
from threading import Lock, RLock
|
from threading import Lock, RLock
|
||||||
|
|
||||||
from telethon.tl import types
|
from telethon.tl import types
|
||||||
|
|
||||||
from .memory import MemorySession, _SentFileType
|
from .memory import MemorySession, _SentFileType
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from ..crypto import AuthKey
|
from ..crypto import AuthKey
|
||||||
|
@ -234,13 +234,16 @@ class SQLiteSession(MemorySession):
|
||||||
'where id = ?', (entity_id,)).fetchone()
|
'where id = ?', (entity_id,)).fetchone()
|
||||||
c.close()
|
c.close()
|
||||||
if row:
|
if row:
|
||||||
return types.updates.State(*row)
|
pts, qts, date, seq = row
|
||||||
|
date = datetime.datetime.utcfromtimestamp(date)
|
||||||
|
return types.updates.State(pts, qts, date, seq, unread_count=0)
|
||||||
|
|
||||||
def set_update_state(self, entity_id, state):
|
def set_update_state(self, entity_id, state):
|
||||||
with self._db_lock:
|
with self._db_lock:
|
||||||
c = self._cursor()
|
c = self._cursor()
|
||||||
c.execute('insert or replace into update_state values (?,?,?,?,?)',
|
c.execute('insert or replace into update_state values (?,?,?,?,?)',
|
||||||
(entity_id, state.pts, state.qts, state.date, state.seq))
|
(entity_id, state.pts, state.qts,
|
||||||
|
state.date.timestamp(), state.seq))
|
||||||
c.close()
|
c.close()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user