about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--litterbox.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/litterbox.c b/litterbox.c
index 8015cec..39fce8f 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -368,9 +368,13 @@ static void handle(struct Message msg) {
 	if (!msg.cmd) return;
 	for (size_t i = 0; i < ARRAY_LEN(Handlers); ++i) {
 		if (strcmp(msg.cmd, Handlers[i].cmd)) continue;
-		dbExec(db, SQL(BEGIN TRANSACTION;));
-		Handlers[i].fn(&msg);
-		dbExec(db, SQL(COMMIT TRANSACTION;));
+		if (Handlers[i].transaction) {
+			dbExec(db, SQL(BEGIN TRANSACTION;));
+			Handlers[i].fn(&msg);
+			dbExec(db, SQL(COMMIT TRANSACTION;));
+		} else {
+			Handlers[i].fn(&msg);
+		}
 		break;
 	}
 }