From 108ba9ab31d387a792b31d85fe3885db99fc3292 Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Fri, 10 Oct 2025 22:15:24 +0200 Subject: [PATCH] partial fix: fix function call for download progress --- core/network/aria2_integration.py | 9 ++++----- core/utils/data/state.py | 1 + main.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 44b778a..fa2b7da 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -5,9 +5,8 @@ from plyer import notification import time def run_aria2p(): - global aria2 - aria2 = aria2p.API( + state.aria2 = aria2p.API( aria2p.Client( host="http://localhost", port=6800, @@ -15,7 +14,7 @@ def run_aria2p(): ) ) - return aria2 + return state.aria2 def aria2server(): @@ -39,7 +38,7 @@ def aria2server(): def dlprogress(): try: - downloads = aria2.get_downloads() + downloads = state.aria2.get_downloads() if downloads: for download in downloads: progress = download.progress_string(0) @@ -52,7 +51,7 @@ def dlprogress(): def send_notification(): while True: try: - downloads = aria2.get_downloads() + downloads = state.aria2.get_downloads() if downloads: for download in downloads: if download.is_complete: diff --git a/core/utils/data/state.py b/core/utils/data/state.py index cb1692d..28ac600 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -13,6 +13,7 @@ class AppState: download_path: str = str(Path.home() / "Downloads") speed_limit: int = 0 aria2process: Optional[Any] = None + aria2: Optional[Any] = None aria2_threads: int = 4 state = AppState(posts=[], post_titles=[], post_urls=[], download_path="") diff --git a/main.py b/main.py index 700aeef..9fcafd5 100644 --- a/main.py +++ b/main.py @@ -26,7 +26,6 @@ def run_gui(): sys.exit(app.exec()) def run_aria2server(): - run_thread(threading.Thread(target=send_notification)) aria2process = aria2server() return aria2process @@ -48,6 +47,7 @@ if __name__ == "__main__": if state.debug: print("Starting Aria2 Server") state.aria2process = run_aria2server() + run_thread(threading.Thread(target=send_notification)) signal.signal(signal.SIGINT, keyboardinterrupthandler) atexit.register(kill_aria2server) if state.debug: