summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2024-11-04 20:48:58 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2024-11-04 20:48:58 +0100
commitd26df5508f26bc3f589b345a30b3758281e6e127 (patch)
tree35c1cd6ae5f997a489e9a54d28b500e6f47375b5
parent8633f92b6dbc7d2c1e7069ddedf10c54f4d31961 (diff)
fixes for older sqlite and python version
-rw-r--r--src/jwebmail/__init__.py2
-rw-r--r--src/jwebmail/read_mails.py10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/jwebmail/__init__.py b/src/jwebmail/__init__.py
index 442590b..fffb551 100644
--- a/src/jwebmail/__init__.py
+++ b/src/jwebmail/__init__.py
@@ -36,7 +36,7 @@ else:
toml_read_file = dict(load=toml_load, text=True)
-__version__ = "2.4.0.dev0"
+__version__ = "2.4.0.dev1"
csrf = CSRFProtect()
diff --git a/src/jwebmail/read_mails.py b/src/jwebmail/read_mails.py
index 05c6e10..cae04b1 100644
--- a/src/jwebmail/read_mails.py
+++ b/src/jwebmail/read_mails.py
@@ -89,10 +89,10 @@ class SqliteTimeoutSession:
self.timeout = timeout
- self.conn = sqlite3.connect(database, autocommit=False)
+ self.conn = sqlite3.connect(database)
cur = self.conn.cursor()
cur.execute(
- "CREATE TABLE IF NOT EXISTS session (user text PRIMARY KEY, password text, timeout real NOT NULL) STRICT"
+ "CREATE TABLE IF NOT EXISTS session (user text PRIMARY KEY, password text, timeout integer NOT NULL) STRICT"
)
cur.execute("CREATE INDEX IF NOT EXISTS timeout_idx ON session (timeout)")
@@ -101,14 +101,14 @@ class SqliteTimeoutSession:
with closing(self.conn.cursor()) as cur:
cur.execute(
- "REPLACE INTO session VALUES (?, ?, unixepoch(?, 'subsec'))",
+ "REPLACE INTO session VALUES (?, ?, unixepoch(?))",
[key, value, timeout],
)
self.conn.commit()
def get(self, key):
with closing(self.conn.cursor()) as cur:
- cur.execute("DELETE FROM session WHERE timeout < unixepoch('subsec')")
+ cur.execute("DELETE FROM session WHERE timeout < unixepoch()")
cur.execute("SELECT password FROM session WHERE user = ?", [key])
row = cur.fetchone()
@@ -118,7 +118,7 @@ class SqliteTimeoutSession:
else:
timeout = datetime.now() + timedelta(seconds=self.timeout)
cur.execute(
- "UPDATE session SET timeout = unixepoch(?, 'subsec') WHERE user = ?",
+ "UPDATE session SET timeout = unixepoch(?) WHERE user = ?",
[timeout, key],
)
self.conn.commit()