Skip to content

Commit 1d8c2f4

Browse files
committed
Default synchronous = NORMAL for sqlite
1 parent 193acb7 commit 1d8c2f4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

mautrix/util/async_db/aiosqlite.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def __init__(
117117
def _add_missing_pragmas(init_commands: list[str]) -> list[str]:
118118
has_foreign_keys = False
119119
has_journal_mode = False
120+
has_synchronous = False
120121
has_busy_timeout = False
121122
for cmd in init_commands:
122123
if "PRAGMA" not in cmd:
@@ -125,12 +126,16 @@ def _add_missing_pragmas(init_commands: list[str]) -> list[str]:
125126
has_foreign_keys = True
126127
elif "journal_mode" in cmd:
127128
has_journal_mode = True
129+
elif "synchronous" in cmd:
130+
has_synchronous = True
128131
elif "busy_timeout" in cmd:
129132
has_busy_timeout = True
130133
if not has_foreign_keys:
131134
init_commands.append("PRAGMA foreign_keys = ON")
132135
if not has_journal_mode:
133136
init_commands.append("PRAGMA journal_mode = WAL")
137+
if not has_synchronous:
138+
init_commands.append("PRAGMA synchronous = NORMAL")
134139
if not has_busy_timeout:
135140
init_commands.append("PRAGMA busy_timeout = 5000")
136141
return init_commands

0 commit comments

Comments
 (0)