From 2c53b11bbf8e1493695a8c839ebc0dcc95f38a48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Tue, 23 Jan 2024 09:13:53 +0200
Subject: [PATCH 1/1] Fixed: Invalid user/cert records after failing to create
user
Subspace name conflict wouldn't cause unrolling of the changes.
model.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/model.py b/model.py
index 7f81977..b904e71 100644
--- a/model.py
+++ b/model.py
@@ -878,8 +878,15 @@ class Database:
cur.execute("DELETE FROM users WHERE id=?", (user_id,))
self.commit()
raise GeminiError(62, 'Certificate not valid')
cur.execute("INSERT INTO subspaces (name, owner) VALUES (?, ?)", (username, user_id))
self.commit()
try:
cur.execute("INSERT INTO subspaces (name, owner) VALUES (?, ?)", (username, user_id))
self.commit()
except:
# Undo the previous database changes.
cur.execute("DELETE FROM users WHERE id=?", (user_id,))
cur.execute("DELETE FROM certs WHERE user=?", (user_id,))
self.commit()
raise GeminiError(50, 'Subspace already exists')
self.notify_admin(Notification.USER_CREATED, user_id)
return user_id
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).