This commit is contained in:
jxxghp 2024-02-20 16:18:29 +08:00
parent 760285b085
commit a8ce9648e2
4 changed files with 11 additions and 8 deletions

View File

@ -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:
"""

View File

@ -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)

View File

@ -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:
"""

View File

@ -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:
"""