]> git.armaanb.net Git - lightcards.git/commitdiff
Don't overwrite existing local config file
authorArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 20:33:02 +0000 (15:33 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 13 Feb 2021 20:33:02 +0000 (15:33 -0500)
setup.py

index 939a7218a215c98921d608bc8cc4da21aed0b3fc..639de5353195fb4c91d698192e3ff31455684537 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,14 +19,17 @@ if os.geteuid() == 0:
     shutil.copyfile("./config.py", "/etc/lightcards/config.py")
 else:
     xdg = os.environ.get("XDG_CONFIG_HOME")
+    xdg_dest = f"{xdg}/lightcards/config.py"
+
     home = os.path.expanduser("~")
+    home_dest = f"{home}/.config/lightcards/config.py"
 
-    if xdg:
+    if xdg and not os.path.exists(xdg_dest):
         mkdir(f"{xdg}/lightcards")
-        shutil.copyfile("./config.py", f"{xdg}/lightcards/config.py")
-    else:
+        shutil.copyfile("./config.py", xdg_dest)
+    elif not os.path.exists(home_dest):
         mkdir(f"{home}/.config/lightcards")
-        shutil.copyfile("./config.py", f"{home}/.config/lightcards/config.py")
+        shutil.copyfile("./config.py", home_dest)
 
 
 setup(