From d64dcf6b012ac35bdec99f12eac3513dcb40d271 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 11 Mar 2024 17:07:58 +0800 Subject: [PATCH] fix LinkMonitor --- package.json | 2 +- plugins/linkmonitor/__init__.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5819366..fb51a84 100644 --- a/package.json +++ b/package.json @@ -354,7 +354,7 @@ "LinkMonitor": { "name": "实时硬链接", "description": "监控目录文件变化,实时硬链接。", - "version": "1.4", + "version": "1.5", "icon": "Linkace_C.png", "author": "jxxghp", "level": 1 diff --git a/plugins/linkmonitor/__init__.py b/plugins/linkmonitor/__init__.py index ed67771..419f52d 100644 --- a/plugins/linkmonitor/__init__.py +++ b/plugins/linkmonitor/__init__.py @@ -51,7 +51,7 @@ class LinkMonitor(_PluginBase): # 插件图标 plugin_icon = "Linkace_C.png" # 插件版本 - plugin_version = "1.4" + plugin_version = "1.5" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -258,8 +258,12 @@ class LinkMonitor(_PluginBase): :param target_path: 目标目录 :param transfer_type: 转移方式 """ - new_file = str(src_path).replace(mon_path, str(target_path)) - new_path = Path(new_file) + # 计算相对路径 + try: + rel_path = src_path.relative_to(Path(mon_path)) + except ValueError: + return False, "文件路径不在监控目录内" + new_path = target_path / rel_path if new_path.exists(): return True, "目标路径文件已存在" else: