Unverified Commit 5e86cc98 authored by Jeff Huffman's avatar Jeff Huffman
Browse files

discord: disableBreakingUpdates: create settings.json when missing

parent 1bddde31
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -22,9 +22,12 @@ XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME") or os.path.join(

settings_path = Path(f"{XDG_CONFIG_HOME}/@configDirName@/settings.json")
settings_path_temp = Path(f"{XDG_CONFIG_HOME}/@configDirName@/settings.json.tmp")
try:

if os.path.exists(settings_path):
    with settings_path.open(encoding="utf-8") as settings_file:
        settings = json.load(settings_file)
else:
    settings = {}

if settings.get("SKIP_HOST_UPDATE"):
    print("[Nix] Disabling updates already done")
@@ -32,11 +35,10 @@ try:
    skip_host_update = {"SKIP_HOST_UPDATE": True}
    settings.update(skip_host_update)

    os.makedirs(os.path.dirname(settings_path), exist_ok=True)

    with settings_path_temp.open("w", encoding="utf-8") as settings_file_temp:
        json.dump(settings, settings_file_temp, indent=2)

    settings_path_temp.rename(settings_path)
    print("[Nix] Disabled updates")

except IOError:
    print("[Nix] settings.json doesn't yet exist, can't disable it yet")