From 5e3d0ec2ada972b74123bf51f320a0ee6951f7c9 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 28 Oct 2023 08:25:43 +0200 Subject: [PATCH] Fix location of config files for executable files (#2917) --- cps/constants.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cps/constants.py b/cps/constants.py index e8c52a68..18c4f1b1 100644 --- a/cps/constants.py +++ b/cps/constants.py @@ -34,6 +34,8 @@ UPDATER_AVAILABLE = True # Base dir is parent of current file, necessary if called from different folder BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)) +# if executable file the files should be placed in the parent dir (parallel to the exe file) + STATIC_DIR = os.path.join(BASE_DIR, 'cps', 'static') TEMPLATES_DIR = os.path.join(BASE_DIR, 'cps', 'templates') TRANSLATIONS_DIR = os.path.join(BASE_DIR, 'cps', 'translations') @@ -49,6 +51,9 @@ if HOME_CONFIG: CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', home_dir) else: CONFIG_DIR = os.environ.get('CALIBRE_DBPATH', BASE_DIR) + if getattr(sys, 'frozen', False): + CONFIG_DIR = os.path.abspath(os.path.join(CONFIG_DIR, os.pardir)) + DEFAULT_SETTINGS_FILE = "app.db" DEFAULT_GDRIVE_FILE = "gdrive.db"