From abdcd46560f32cad8a9c9b3915fc7b7c58937caa Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 27 Jun 2024 15:56:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BB=85=E6=A3=80=E6=9F=A5=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=EF=BC=8C=E9=A2=84=E8=A7=88=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=88=A0=E9=99=A4=E4=BB=BB=E4=BD=95=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/libraryduplicatecheck/__init__.py | 41 +++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/plugins/libraryduplicatecheck/__init__.py b/plugins/libraryduplicatecheck/__init__.py index 5c62388..ce806b5 100644 --- a/plugins/libraryduplicatecheck/__init__.py +++ b/plugins/libraryduplicatecheck/__init__.py @@ -247,30 +247,29 @@ class LibraryDuplicateCheck(_PluginBase): else: logger.info(f" {path} 文件已被删除") - if str(retain_type) != "仅检查": - # Decide which file to keep based on criteria (e.g., file size or creation date) - keep_file = self.__choose_file_to_keep(paths, retain_type) - keep_cloud_file = os.readlink(keep_file) + # Decide which file to keep based on criteria (e.g., file size or creation date) + keep_file = self.__choose_file_to_keep(paths, retain_type) + keep_cloud_file = os.readlink(keep_file) - logger.info(f"文件保留规则:{str(retain_type)} Keeping: {keep_file}") - # Delete the other duplicate files (if needed) - for path in paths: - if (Path(path).exists() or os.path.islink(path)) and str(path) != str(keep_file): - cloud_file = os.readlink(path) - delete_duplicate_files += 1 - self.__delete_duplicate_file(duplicate_file=path, + logger.info(f"文件保留规则:{str(retain_type)} Keeping: {keep_file}") + # Delete the other duplicate files (if needed) + for path in paths: + if (Path(path).exists() or os.path.islink(path)) and str(path) != str(keep_file): + cloud_file = os.readlink(path) + delete_duplicate_files += 1 + self.__delete_duplicate_file(duplicate_file=path, + paths=paths, + keep_file=keep_file, + file_type="监控", + retain_type=retain_type) + # 同步删除软连接源目录 + if cloud_file and Path(cloud_file).exists() and self._delete_softlink: + delete_cloud_files += 1 + self.__delete_duplicate_file(duplicate_file=cloud_file, paths=paths, - keep_file=keep_file, - file_type="监控", + keep_file=keep_cloud_file, + file_type="云盘", retain_type=retain_type) - # 同步删除软连接源目录 - if cloud_file and Path(cloud_file).exists() and self._delete_softlink: - delete_cloud_files += 1 - self.__delete_duplicate_file(duplicate_file=cloud_file, - paths=paths, - keep_file=keep_cloud_file, - file_type="云盘", - retain_type=retain_type) else: logger.info(f"'{name}' No Duplicate video files.")