From bdf61eb7dde9338ee0afa3b0733759b7faf08a4f Mon Sep 17 00:00:00 2001 From: Leela Prasad <47483946+leelaprasadv@users.noreply.github.com> Date: Tue, 28 Nov 2023 22:15:08 +0530 Subject: [PATCH] Copy properties file only if not exist and once --- hamster/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hamster/config.py b/hamster/config.py index 67b97aa..8944182 100644 --- a/hamster/config.py +++ b/hamster/config.py @@ -15,13 +15,13 @@ source_path = os.path.join(os.path.dirname(sys.argv[0]), app_properties_template) # Define the destination path (user's home directory) -destination_path = os.path.join(home_dir, app_properties_template) +properties_file_path = os.path.join(home_dir, app_properties_template) -# Use shutil to copy the file -shutil.copy(source_path, destination_path) +# Use shutil to copy the file if file doesn't exist +if not os.path.exists(properties_file_path): + shutil.copy(source_path, properties_file_path) config_parser = configparser.ConfigParser() -properties_file_path = os.path.join(home_dir, app_properties_template) config_parser.read(properties_file_path) icon_path = os.path.join(os.path.dirname(sys.argv[0]), 'img/hamster.png')