From 390d0ff9aabd83fb3fdf8779fc3c0ff6b3296e34 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sun, 14 Jul 2024 17:20:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=B8=85=E7=90=86?= =?UTF-8?q?=E6=97=A0=E6=95=88=E8=BD=AF=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/cloudassistant/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/cloudassistant/__init__.py b/plugins/cloudassistant/__init__.py index f31a464..4b171f7 100644 --- a/plugins/cloudassistant/__init__.py +++ b/plugins/cloudassistant/__init__.py @@ -894,9 +894,18 @@ class CloudAssistant(_PluginBase): for root, dirs, files in os.walk(mon_path): for name in dirs + files: file_path = os.path.join(root, name) - if Path(str(file_path)).is_file() and self.is_broken_symlink(str(file_path)): + if Path(str(file_path)).is_symlink() and self.is_broken_symlink(file_path): print(f"删除无效软连接: {file_path}") os.remove(file_path) + + # 判断文件夹是否可删除 + for file_dir in Path(str(file_path)).parents: + if not SystemUtils.list_files(file_dir, [ext.strip() for ext in + self._rmt_mediaext.split( + ",")] + settings.DOWNLOAD_TMPEXT): + logger.warn(f"删除空目录:{file_dir}") + shutil.rmtree(file_dir, ignore_errors=True) + logger.info("云盘助手清理无效软连接完成!") def __refresh_emby(self, transferinfo):