From f9d62e74510f7ae4ae651d29a586076b6704472f Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 12 Nov 2024 10:10:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20Rclone=E5=AD=98=E5=82=A8=E5=AE=B9?= =?UTF-8?q?=E9=87=8F=E6=A3=80=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/filemanager/storages/rclone.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/modules/filemanager/storages/rclone.py b/app/modules/filemanager/storages/rclone.py index f3fc9d4a..4b3a3661 100644 --- a/app/modules/filemanager/storages/rclone.py +++ b/app/modules/filemanager/storages/rclone.py @@ -331,11 +331,24 @@ class Rclone(StorageBase): """ 存储使用情况 """ + conf = self.get_config() + if not conf: + return None + file_path = conf.config.get("filepath") + if not file_path or not Path(file_path).exists(): + return None + # 读取rclone文件,检查是否有[MP]节点配置 + with open(file_path, "r", encoding="utf-8") as f: + lines = f.readlines() + if not lines: + return None + if not any("[MP]" in line.strip() for line in lines): + return None try: ret = subprocess.run( [ 'rclone', 'about', - '/', '--json' + 'MP:/', '--json' ], capture_output=True, startupinfo=self.__get_hidden_shell()