mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
feat: add download existence checks and improve log removal feedback
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.utils.logging.logs import consoleLog, remove_download_log
|
||||
from core.utils.network.download import run_download_direct
|
||||
|
||||
import os
|
||||
|
||||
def split_data(data):
|
||||
|
||||
count = data.count
|
||||
@@ -16,6 +18,11 @@ def check_completed(downloads, resume):
|
||||
run_download_direct(download.magnet_uri)
|
||||
consoleLog(f"Resuming {download.title}")
|
||||
|
||||
|
||||
|
||||
|
||||
def check_downloads(downloads):
|
||||
for download in downloads:
|
||||
if os.path.exists(download.path):
|
||||
consoleLog(f"Existing Download: {download.title}")
|
||||
else:
|
||||
consoleLog(f"Inexistent Download: {download.title}")
|
||||
remove_download_log(download.magnet_uri)
|
||||
|
||||
@@ -77,10 +77,12 @@ def remove_download_log(magnet_uri) -> DownloadList:
|
||||
else:
|
||||
downloads = []
|
||||
|
||||
|
||||
magnet_link = (magnet_uri or "").strip()
|
||||
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))
|
||||
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]
|
||||
|
||||
consoleLog(f"Removed {magnet_link} from Log File")
|
||||
consoleLog(f"Removed {title} from Log File")
|
||||
|
||||
download_list = DownloadList(data=downloads, count=len(downloads))
|
||||
with open(downloads_file, "w") as file:
|
||||
|
||||
Reference in New Issue
Block a user