mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
add download speed limit setting
This commit is contained in:
@@ -7,7 +7,7 @@ from core.utils.data.state import state
|
||||
def create_config():
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}"}
|
||||
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}"}
|
||||
|
||||
if platform.system() == "Windows":
|
||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||
@@ -41,4 +41,5 @@ def read_config():
|
||||
state.api_url = config.get("General", "api_url")
|
||||
state.aria2_threads = config.getint("General", "aria2_threads")
|
||||
state.download_path = config.get("General", "download_path")
|
||||
state.speed_limit = config.getint("General", "speed_limit")
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from core.utils.data.state import state
|
||||
from .config import create_config
|
||||
import os
|
||||
|
||||
def restart_aria2c():
|
||||
import main # had to do this because of circle import :(
|
||||
@@ -13,10 +12,11 @@ def restart_aria2c():
|
||||
atexit.unregister(main.kill_aria2server)
|
||||
atexit.register(main.kill_aria2server)
|
||||
|
||||
def save_settings(thread_count, close, apiurl, download_path):
|
||||
def save_settings(thread_count, close, apiurl, download_path, speed_limit):
|
||||
state.aria2_threads = thread_count
|
||||
state.api_url = apiurl
|
||||
state.download_path = download_path
|
||||
state.speed_limit = speed_limit
|
||||
|
||||
create_config()
|
||||
restart_aria2c()
|
||||
|
||||
@@ -11,6 +11,7 @@ class AppState:
|
||||
tracker: str = "rutracker"
|
||||
api_url: str = "https://api.michijackson.xyz"
|
||||
download_path: str = str(Path.home() / "Downloads")
|
||||
speed_limit: int = 0
|
||||
aria2process: Optional[Any] = None
|
||||
aria2_threads: int = 4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user