From 9650dc76ebe4c7fdedd1c5834444c97f56348a50 Mon Sep 17 00:00:00 2001 From: Tim K Date: Sun, 30 Jul 2023 09:05:12 -0400 Subject: [PATCH] config: Set the config path when we read the file Fixes #79. cfg_path was a terrible decision, and really shouldn't exist. The idea was for the config object to keep track of where it was loaded from -- but I'm abusing the ever loving stuffing out of it, and it should be removed in a future release. For the time being, however, I'm moving this line within the conditional to ensure that cfg_path is only set when we are directly reading a file on the disk. It's pedantic, but hopefully this will prevent any further undefined behavior until I can revamp the config system. --- taky/config.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/taky/config.py b/taky/config.py index f8d9d76..229a7fc 100644 --- a/taky/config.py +++ b/taky/config.py @@ -67,6 +67,9 @@ def load_config(path=None, explicit=False): cfg_dir = os.path.realpath(os.path.dirname(path)) with open(path, "r", encoding="utf8") as cfg_fp: ret_config.read_file(cfg_fp, source=path) + + # We know the file exists now, set the config path + ret_config.set("taky", "cfg_path", path) elif explicit: raise FileNotFoundError("Config file required, but not present") else: @@ -75,9 +78,6 @@ def load_config(path=None, explicit=False): ret_config.set("taky", "root_dir", ".") ret_config.set("dp_server", "upload_path", "./dp-user") - - # Set the config path - ret_config.set("taky","cfg_path",path) # Make directories absolute for (sect, opt) in [ @@ -136,7 +136,5 @@ def load_config(path=None, explicit=False): f_path = os.path.realpath(os.path.join(cfg_dir, f_path)) ret_config.set("ssl", f_name, f_path) - - app_config.clear() app_config.update(ret_config)