Fix sync token behaviour
This commit is contained in:
parent
668a892e8c
commit
fc448a6ba1
2 changed files with 10 additions and 4 deletions
|
@ -44,5 +44,5 @@ class Storage(object):
|
||||||
def _run_migrations(self):
|
def _run_migrations(self):
|
||||||
"""Execute database migrations"""
|
"""Execute database migrations"""
|
||||||
# Initialize a connection to the database
|
# Initialize a connection to the database
|
||||||
conn = sqlite3.connect(self.db_path)
|
self.conn = sqlite3.connect(self.db_path)
|
||||||
self.cursor = conn.cursor()
|
self.cursor = self.conn.cursor()
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class SyncToken(object):
|
class SyncToken(object):
|
||||||
"""A SyncToken is an instance of a sync token, which is a token retrieved from a matrix
|
"""A SyncToken is an instance of a sync token, which is a token retrieved from a matrix
|
||||||
homeserver. It is given to the /sync endpoint in order to specify at which point in the
|
homeserver. It is given to the /sync endpoint in order to specify at which point in the
|
||||||
|
@ -24,10 +28,12 @@ class SyncToken(object):
|
||||||
self.token = rows[0]
|
self.token = rows[0]
|
||||||
|
|
||||||
def update(self, token):
|
def update(self, token):
|
||||||
"""Update the sync token in the database
|
"""Update the sync token in the database and the object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
token (str): A sync token from a sync response sent by a matrix homeserver
|
token (str): A sync token from a sync response sent by a matrix homeserver
|
||||||
"""
|
"""
|
||||||
|
self.token = token
|
||||||
self.store.cursor.execute("INSERT OR REPLACE INTO sync_token "
|
self.store.cursor.execute("INSERT OR REPLACE INTO sync_token "
|
||||||
"(token) VALUES (?)", (token,))
|
"(dedupe_id, token) VALUES (1, ?)", (token,))
|
||||||
|
self.store.conn.commit()
|
||||||
|
|
Loading…
Reference in a new issue