From 952cae50e227ce38b001d437607e08b34e759cd5 Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 6 Sep 2023 15:57:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=90=8C=E6=AD=A5=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=88=A0=E7=A7=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/mediasyncdel/__init__.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/plugins/mediasyncdel/__init__.py b/app/plugins/mediasyncdel/__init__.py index 1970b6d9..190c630a 100644 --- a/app/plugins/mediasyncdel/__init__.py +++ b/app/plugins/mediasyncdel/__init__.py @@ -831,11 +831,22 @@ class MediaSyncDel(_PluginBase): # 删除本次种子记录 self._downloadhis.delete_file_by_fullpath(fullpath=src) - # 根据种子hash查询剩余未删除的记录 - downloadHisNoDel = self._downloadhis.get_files_by_hash(download_hash=torrent_hash, state=1) - if downloadHisNoDel and len(downloadHisNoDel) > 0: + # 根据种子hash查询所有下载器文件记录 + download_files = self._downloadhis.get_files_by_hash(download_hash=torrent_hash) + if not download_files: + logger.error( + f"未查询到种子任务 {torrent_hash} 存在文件记录,未执行下载器文件同步或该种子已被删除") + return False, False + + # 查询未删除数 + no_del_cnt = 0 + for download_file in download_files: + if download_file and download_file.state and int(download_file.state) == 1: + no_del_cnt += 1 + + if no_del_cnt > 0: logger.info( - f"查询种子任务 {torrent_hash} 存在 {len(downloadHisNoDel)} 个未删除文件,执行暂停种子操作") + f"查询种子任务 {torrent_hash} 存在 {no_del_cnt} 个未删除文件,执行暂停种子操作") delete_flag = False else: logger.info(