Add update_state table to persist pts and such

This commit is contained in:
Lonami Exo 2018-04-23 21:16:09 +02:00
parent e616af8a70
commit ea404c5477

View File

@ -13,7 +13,7 @@ from ..tl.types import (
)
EXTENSION = '.session'
CURRENT_VERSION = 3 # database version
CURRENT_VERSION = 4 # database version
class SQLiteSession(MemorySession):
@ -99,6 +99,14 @@ class SQLiteSession(MemorySession):
hash integer,
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,))
# Migrating from JSON -> new table and may have entities
@ -141,8 +149,11 @@ class SQLiteSession(MemorySession):
def _upgrade_database(self, old):
c = self._cursor()
if old == 1:
old += 1
# old == 1 doesn't have the old sent_files so no need to drop
if old == 2:
old += 1
# Old cache from old sent_files lasts then a day anyway, drop
c.execute('drop table sent_files')
self._create_table(c, """sent_files (
@ -153,6 +164,15 @@ class SQLiteSession(MemorySession):
hash integer,
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()
@staticmethod