Added support for disabling auto-updates via a new config file

This commit is contained in:
2025-04-21 23:27:36 -04:00
parent 1e0fda7407
commit bcb86bc4b0
12 changed files with 488 additions and 305 deletions

View File

@@ -1,6 +1,9 @@
# "modules/core.py", licensed under the MIT license
# Copyright 2024-2025 NinjaCheetah
import os
import json
import pathlib
import requests
from dataclasses import dataclass
from typing import List
@@ -60,3 +63,21 @@ def check_nusget_updates(app, current_version: str, progress_callback=None) -> s
return new_version
progress_callback.emit(app.translate("MainWindow", "\n\nYou're running the latest release of NUSGet."))
return None
def get_config_file() -> pathlib.Path:
config_dir = pathlib.Path(os.path.join(
os.environ.get('APPDATA') or
os.environ.get('XDG_CONFIG_HOME') or
os.path.join(os.environ['HOME'], '.config'),
"NUSGet"
))
config_dir.mkdir(exist_ok=True)
return config_dir.joinpath("config.json")
def save_config(config_data: dict) -> None:
config_file = get_config_file()
open(config_file, "w").write(json.dumps(config_data))
def update_setting(config_data: dict, setting: str, value: any) -> None:
config_data[setting] = value
save_config(config_data)