fix: improve checks for logging

This commit is contained in:
Vxrtrauter
2026-03-10 15:52:15 +01:00
parent 5369578194
commit 8d6d02a1af
+7 -3
View File
@@ -40,13 +40,14 @@ def _add_download_log_inner(title, url, magnet_uri, completed, path) -> Download
else: else:
downloads = [] downloads = []
if any(d.magnet_uri == magnet_uri or d.url == url for d in downloads): if any((magnet_uri and d.magnet_uri == magnet_uri) or (url and d.url == url) for d in downloads):
if magnet_uri in state.active_downloads: if magnet_uri and magnet_uri in state.active_downloads:
consoleLog("Skipping Logging, download already running...") consoleLog("Skipping Logging, download already running...")
return DownloadList(data=downloads, count=len(downloads)) return DownloadList(data=downloads, count=len(downloads))
consoleLog("File already in Log, updating Download State...") consoleLog("File already in Log, updating Download State...")
hash = extract_hash_from_magnet(magnet_uri) hash = extract_hash_from_magnet(magnet_uri)
update_download_completed_by_hash(hash, False) if hash:
update_download_completed_by_hash(hash, False)
return DownloadList(data=downloads, count=len(downloads)) return DownloadList(data=downloads, count=len(downloads))
@@ -85,6 +86,9 @@ def _remove_download_log_inner(magnet_uri) -> DownloadList:
magnet_link = (magnet_uri or "").strip() magnet_link = (magnet_uri or "").strip()
if not magnet_link:
return DownloadList(data=downloads, count=len(downloads))
title = next((getattr(d, 'title', 'Unknown') for d in downloads if (getattr(d, 'magnet_uri', None) or '').strip() == magnet_link or (getattr(d, 'url', None) or '').strip() == magnet_link), 'Unknown') title = next((getattr(d, 'title', 'Unknown') for d in downloads if (getattr(d, 'magnet_uri', None) or '').strip() == magnet_link or (getattr(d, 'url', None) or '').strip() == magnet_link), 'Unknown')
downloads = [d for d in downloads if (getattr(d, 'magnet_uri', None) or "").strip() != magnet_link and (getattr(d, 'url', None) or "").strip() != magnet_link] downloads = [d for d in downloads if (getattr(d, 'magnet_uri', None) or "").strip() != magnet_link and (getattr(d, 'url', None) or "").strip() != magnet_link]