mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Add update_state table to persist pts and such
This commit is contained in:
parent
e616af8a70
commit
ea404c5477
|
@ -13,7 +13,7 @@ from ..tl.types import (
|
||||||
)
|
)
|
||||||
|
|
||||||
EXTENSION = '.session'
|
EXTENSION = '.session'
|
||||||
CURRENT_VERSION = 3 # database version
|
CURRENT_VERSION = 4 # database version
|
||||||
|
|
||||||
|
|
||||||
class SQLiteSession(MemorySession):
|
class SQLiteSession(MemorySession):
|
||||||
|
@ -99,6 +99,14 @@ class SQLiteSession(MemorySession):
|
||||||
hash integer,
|
hash integer,
|
||||||
primary key(md5_digest, file_size, type)
|
primary key(md5_digest, file_size, type)
|
||||||
)"""
|
)"""
|
||||||
|
,
|
||||||
|
"""update_state (
|
||||||
|
id integer primary key,
|
||||||
|
pts integer,
|
||||||
|
qts integer,
|
||||||
|
date integer,
|
||||||
|
seq integer
|
||||||
|
)"""
|
||||||
)
|
)
|
||||||
c.execute("insert into version values (?)", (CURRENT_VERSION,))
|
c.execute("insert into version values (?)", (CURRENT_VERSION,))
|
||||||
# Migrating from JSON -> new table and may have entities
|
# Migrating from JSON -> new table and may have entities
|
||||||
|
@ -141,18 +149,30 @@ class SQLiteSession(MemorySession):
|
||||||
|
|
||||||
def _upgrade_database(self, old):
|
def _upgrade_database(self, old):
|
||||||
c = self._cursor()
|
c = self._cursor()
|
||||||
# old == 1 doesn't have the old sent_files so no need to drop
|
if old == 1:
|
||||||
|
old += 1
|
||||||
|
# old == 1 doesn't have the old sent_files so no need to drop
|
||||||
if old == 2:
|
if old == 2:
|
||||||
|
old += 1
|
||||||
# Old cache from old sent_files lasts then a day anyway, drop
|
# Old cache from old sent_files lasts then a day anyway, drop
|
||||||
c.execute('drop table sent_files')
|
c.execute('drop table sent_files')
|
||||||
self._create_table(c, """sent_files (
|
self._create_table(c, """sent_files (
|
||||||
md5_digest blob,
|
md5_digest blob,
|
||||||
file_size integer,
|
file_size integer,
|
||||||
type integer,
|
type integer,
|
||||||
id integer,
|
id integer,
|
||||||
hash integer,
|
hash integer,
|
||||||
primary key(md5_digest, file_size, type)
|
primary key(md5_digest, file_size, type)
|
||||||
)""")
|
)""")
|
||||||
|
if old == 3:
|
||||||
|
old += 1
|
||||||
|
self._create_table(c, """update_state (
|
||||||
|
id integer primary key,
|
||||||
|
pts integer,
|
||||||
|
qts integer,
|
||||||
|
date integer,
|
||||||
|
seq integer
|
||||||
|
)""")
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user