From 4cd1fccaa332ca4fd9d7b766a964eb0cbefb4273 Mon Sep 17 00:00:00 2001 From: Tang Vu Date: Sun, 22 Mar 2026 00:06:36 +0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor:=20Hardcoded=20re?= =?UTF-8?q?lative=20path=20for=20database=20file=20(#2285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: hardcoded relative path for database file `app.config['MAIGRET_DB_FILE']` is set to a hardcoded relative path `os.path.join('maigret', 'resources', 'data.json')`. If the Flask application is executed from a different working directory (other than the repository root), it will fail to find the database file and crash. Affected files: app.py, settings.py * refactor: hardcoded relative path for database file `app.config['MAIGRET_DB_FILE']` is set to a hardcoded relative path `os.path.join('maigret', 'resources', 'data.json')`. If the Flask application is executed from a different working directory (other than the repository root), it will fail to find the database file and crash. Affected files: app.py, settings.py --- maigret/settings.py | 2 +- maigret/web/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maigret/settings.py b/maigret/settings.py index a355d39..5c927fa 100644 --- a/maigret/settings.py +++ b/maigret/settings.py @@ -5,7 +5,7 @@ from typing import List SETTINGS_FILES_PATHS = [ path.join(path.dirname(path.realpath(__file__)), "resources/settings.json"), - '~/.maigret/settings.json', + path.expanduser('~/.maigret/settings.json'), path.join(os.getcwd(), 'settings.json'), ] diff --git a/maigret/web/app.py b/maigret/web/app.py index dedc31d..d5eabc3 100644 --- a/maigret/web/app.py +++ b/maigret/web/app.py @@ -27,7 +27,7 @@ background_jobs = {} job_results = {} # Configuration -app.config["MAIGRET_DB_FILE"] = os.path.join('maigret', 'resources', 'data.json') +app.config["MAIGRET_DB_FILE"] = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'data.json') app.config["COOKIES_FILE"] = "cookies.txt" app.config["UPLOAD_FOLDER"] = 'uploads' app.config["REPORTS_FOLDER"] = os.path.abspath('/tmp/maigret_reports')