Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add a check to SQLite port DB script to ensure that the sqlite database passed to the script exists before trying to port from it #15306

Merged
merged 3 commits into from Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/15306.bugfix
@@ -0,0 +1,2 @@
Add a check to [SQLite port_db script](https://matrix-org.github.io/synapse/latest/postgres.html#porting-from-sqlite)
to ensure that the sqlite database passed to the script exists before trying to port from it.
8 changes: 8 additions & 0 deletions synapse/_scripts/synapse_port_db.py
Expand Up @@ -18,6 +18,7 @@
import argparse
import curses
import logging
import os
import sys
import time
import traceback
Expand Down Expand Up @@ -1326,6 +1327,13 @@ def main() -> None:
filename="port-synapse.log" if args.curses else None,
)

if not os.path.isfile(args.sqlite_database):
sys.stderr.write(
"The sqlite database you specified does not exist, please check that you have the"
"correct path."
)
sys.exit(1)

sqlite_config = {
"name": "sqlite3",
"args": {
Expand Down