From 766ce8542db3cb2cbff179c1138235b41ff621f0 Mon Sep 17 00:00:00 2001 From: Fil Sapia Date: Thu, 9 Oct 2025 00:01:13 +0100 Subject: [PATCH] Ensure configuration directory exists before copying config file --- monitor-setup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/monitor-setup.py b/monitor-setup.py index 25cb46e..e2d61b5 100644 --- a/monitor-setup.py +++ b/monitor-setup.py @@ -6,8 +6,11 @@ import shutil class MonitorSetup(): def __init__(self): self._stg_conf_file = "monitor.conf" - self._conf_file_path = os.path.join(os.path.expanduser('~'), - ".config/hdr-helper",self._stg_conf_file) + self._conf_file_dir = os.path.join(os.path.expanduser('~'), + ".config/hdr-helper") + self._conf_file_path = os.path.join(self._conf_file_dir, + self._stg_conf_file) + ################################ self.default_mode = None self.alt_rate = None @@ -80,6 +83,9 @@ class MonitorSetup(): file.write(line) def copy_config_file(self): + if not os.path.exists(self._conf_file_dir): + os.makedirs(self._conf_file_dir) + # Backup existing config file if it exists if os.path.isfile(self._conf_file_path): shutil.move(self._conf_file_path, self._conf_file_path + ".backup" )