From 03d9bf6d05d08e9bed7878da946a8bb2a2022e4c Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 5 Sep 2023 16:20:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20=E8=B7=AF=E5=BE=84=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/nastoolsync/__init__.py | 2 +- app/plugins/syncdownloadfiles/__init__.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/plugins/nastoolsync/__init__.py b/app/plugins/nastoolsync/__init__.py index 3c47e530..a66fc8cc 100644 --- a/app/plugins/nastoolsync/__init__.py +++ b/app/plugins/nastoolsync/__init__.py @@ -387,7 +387,7 @@ class NAStoolSync(_PluginBase): mdest = mdest.replace(sub_paths[0], sub_paths[1]).replace('\\', '/') # 存库 - self._transferhistory.add_force( + self._transferhistory.add( src=msrc, dest=mdest, mode=mmode, diff --git a/app/plugins/syncdownloadfiles/__init__.py b/app/plugins/syncdownloadfiles/__init__.py index 8edb5b1d..a912fe04 100644 --- a/app/plugins/syncdownloadfiles/__init__.py +++ b/app/plugins/syncdownloadfiles/__init__.py @@ -149,13 +149,6 @@ class SyncDownloadFiles(_PluginBase): # 获取种子download_dir download_dir = self.__get_download_dir(torrent, downloader) - # 获取种子name - torrent_name = self.__get_torrent_name(torrent, downloader) - # 种子保存目录 - save_path = Path(download_dir).joinpath(torrent_name) - # 获取种子文件 - torrent_files = self.__get_torrent_files(torrent, downloader, downloader_obj) - logger.info(f"开始同步种子 {hash_str}, 文件数 {len(torrent_files)}") # 处理路径映射 if self._dirs: @@ -164,6 +157,14 @@ class SyncDownloadFiles(_PluginBase): sub_paths = path.split(":") download_dir = download_dir.replace(sub_paths[0], sub_paths[1]).replace('\\', '/') + # 获取种子name + torrent_name = self.__get_torrent_name(torrent, downloader) + # 种子保存目录 + save_path = Path(download_dir).joinpath(torrent_name) + # 获取种子文件 + torrent_files = self.__get_torrent_files(torrent, downloader, downloader_obj) + logger.info(f"开始同步种子 {hash_str}, 文件数 {len(torrent_files)}") + download_files = [] for file in torrent_files: # 种子文件路径 From 7435fb0c10234e083e25dca957242bbb0a2b4f21 Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 5 Sep 2023 16:52:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20tr=E6=96=87=E4=BB=B6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E8=BF=87=E6=BB=A4=E6=8E=89=E6=9C=AA=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/syncdownloadfiles/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/plugins/syncdownloadfiles/__init__.py b/app/plugins/syncdownloadfiles/__init__.py index a912fe04..31cf6ad2 100644 --- a/app/plugins/syncdownloadfiles/__init__.py +++ b/app/plugins/syncdownloadfiles/__init__.py @@ -167,6 +167,9 @@ class SyncDownloadFiles(_PluginBase): download_files = [] for file in torrent_files: + # 过滤掉没下载的文件 + if not self.__is_download(file, downloader): + continue # 种子文件路径 file_path_str = self.__get_file_path(file, downloader) file_path = Path(file_path_str) @@ -282,6 +285,20 @@ class SyncDownloadFiles(_PluginBase): return True + @staticmethod + def __is_download(file: Any, dl_type: str): + """ + 判断文件是否被下载 + """ + try: + if dl_type == "qbittorrent": + return True + else: + return file.completed and file.completed > 0 + except Exception as e: + print(str(e)) + return True + @staticmethod def __get_file_path(file: Any, dl_type: str): """