From 75c649afdaec58c09678e478c281184959e9047d Mon Sep 17 00:00:00 2001 From: KeksNino Date: Tue, 7 Apr 2026 23:44:38 +0200 Subject: [PATCH] feat: move to trash instead of deleting permanently when deleting files --- requirements.txt | 1 + src/interface/dialogs/contextmenu.py | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0fecfdd..fa53177 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ plyer==2.1.0 psutil==7.1.0 libtorrent==2.0.11 libtorrent-windows-dll==0.0.3 +send2trash==2.1.0 diff --git a/src/interface/dialogs/contextmenu.py b/src/interface/dialogs/contextmenu.py index 327b7ba..837e1a1 100644 --- a/src/interface/dialogs/contextmenu.py +++ b/src/interface/dialogs/contextmenu.py @@ -134,14 +134,11 @@ class ContextMenu_Downloads: except Exception as e: consoleLog(f"Exception while removing download from LibTorrent: {e}") if download_path and os.path.exists(download_path): - import shutil last_error = None for attempt in range(3): try: if os.path.isfile(download_path): - os.remove(download_path) - else: - shutil.rmtree(download_path) + send2trash(download_path) consoleLog(f"Deleted files for: {torrent_name}", True) last_error = None break