mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
fix: tracker context menu logic and server name
contextmenu.py: Harden context-menu handlers by validating row bounds against state.posts, avoid relying on selectedItems() in places where _context_menu_row is used, and handle directory paths when deleting downloads (os.path.isdir or isfile) before send2trash. Also streamline URL opening with exception handling. main.py: Update SERVER_NAME to "SoftwareManager_KeksPirates". These changes prevent out-of-range/selection errors and ensure directories are trashed safely; also update server identification.
This commit is contained in:
@@ -186,7 +186,7 @@ class ContextMenu_Downloads:
|
||||
last_error = None
|
||||
for attempt in range(3):
|
||||
try:
|
||||
if os.path.isfile(download_path):
|
||||
if os.path.isfile(download_path) or os.path.isdir(download_path):
|
||||
send2trash(download_path)
|
||||
consoleLog(f"Deleted files for: {torrent_name}", True)
|
||||
last_error = None
|
||||
@@ -226,16 +226,8 @@ class ContextMenu_TrackerTable:
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.trackers):
|
||||
return
|
||||
|
||||
selected = state.trackertable.selectedItems()
|
||||
if not selected:
|
||||
return
|
||||
|
||||
row = selected[0].row()
|
||||
|
||||
if not state.posts or row >= len(state.posts):
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
post = state.posts[row]
|
||||
@@ -257,13 +249,10 @@ class ContextMenu_TrackerTable:
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.trackers):
|
||||
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
item = list(state.trackertable.selectedItems())[0]
|
||||
row = item.row()
|
||||
|
||||
if state.posts:
|
||||
post = state.posts[row]
|
||||
url = post.get("url")
|
||||
if url:
|
||||
@@ -274,7 +263,7 @@ class ContextMenu_TrackerTable:
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.trackers):
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
run_thread(threading.Thread(target=download_selected, args=(state.trackertable.selectedItems(),)))
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import signal
|
||||
import time
|
||||
import sys
|
||||
|
||||
SERVER_NAME = "SoftwareManager_python"
|
||||
SERVER_NAME = "SoftwareManager_KeksPirates"
|
||||
|
||||
class SingleInstance(QObject):
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user