From d26df5508f26bc3f589b345a30b3758281e6e127 Mon Sep 17 00:00:00 2001
From: "Jannis M. Hoffmann" <jannis@fehcom.de>
Date: Mon, 4 Nov 2024 20:48:58 +0100
Subject: fixes for older sqlite and python version

---
 src/jwebmail/__init__.py   |  2 +-
 src/jwebmail/read_mails.py | 10 +++++-----
 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()
-- 
cgit v1.2.3