diff --git a/app/chain/__init__.py b/app/chain/__init__.py index f432416f..7f19a65a 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -342,13 +342,14 @@ class ChainBase(metaclass=ABCMeta): """ return self.run_module("transfer_completed", hashs=hashs, path=path) - def remove_torrents(self, hashs: Union[str, list]) -> bool: + def remove_torrents(self, hashs: Union[str, list], delete_file: bool = True) -> bool: """ 删除下载器种子 :param hashs: 种子Hash + :param delete_file: 是否删除文件 :return: bool """ - return self.run_module("remove_torrents", hashs=hashs) + return self.run_module("remove_torrents", hashs=hashs, delete_file=delete_file) def start_torrents(self, hashs: Union[list, str]) -> bool: """ diff --git a/app/chain/download.py b/app/chain/download.py index 5b7f9a13..b08b899d 100644 --- a/app/chain/download.py +++ b/app/chain/download.py @@ -850,5 +850,5 @@ class DownloadChain(ChainBase): hash_str = event.event_data.get("hash") if not hash_str: return - logger.warn(f"检测到下载源文件被删除,删除下载任务:{hash_str}") - self.remove_torrents(hashs=[hash_str]) + logger.warn(f"检测到下载源文件被删除,删除下载任务(不含文件):{hash_str}") + self.remove_torrents(hashs=[hash_str], delete_file=False) diff --git a/app/modules/qbittorrent/__init__.py b/app/modules/qbittorrent/__init__.py index 5c26ee85..d193fa2a 100644 --- a/app/modules/qbittorrent/__init__.py +++ b/app/modules/qbittorrent/__init__.py @@ -236,13 +236,14 @@ class QbittorrentModule(_ModuleBase): logger.warn(f"删除残留文件夹:{path}") shutil.rmtree(path, ignore_errors=True) - def remove_torrents(self, hashs: Union[str, list]) -> bool: + def remove_torrents(self, hashs: Union[str, list], delete_file: bool = True) -> bool: """ 删除下载器种子 :param hashs: 种子Hash + :param delete_file: 是否删除文件 :return: bool """ - return self.qbittorrent.delete_torrents(delete_file=True, ids=hashs) + return self.qbittorrent.delete_torrents(delete_file=delete_file, ids=hashs) def start_torrents(self, hashs: Union[list, str]) -> bool: """ diff --git a/app/modules/transmission/__init__.py b/app/modules/transmission/__init__.py index 60411612..505311e7 100644 --- a/app/modules/transmission/__init__.py +++ b/app/modules/transmission/__init__.py @@ -220,13 +220,14 @@ class TransmissionModule(_ModuleBase): logger.warn(f"删除残留文件夹:{path}") shutil.rmtree(path, ignore_errors=True) - def remove_torrents(self, hashs: Union[str, list]) -> bool: + def remove_torrents(self, hashs: Union[str, list], delete_file: bool = True) -> bool: """ 删除下载器种子 :param hashs: 种子Hash + :param delete_file: 是否删除文件 :return: bool """ - return self.transmission.delete_torrents(delete_file=True, ids=hashs) + return self.transmission.delete_torrents(delete_file=delete_file, ids=hashs) def start_torrents(self, hashs: Union[list, str]) -> bool: """