fix LinkMonitor

This commit is contained in:
jxxghp
2024-03-11 17:07:58 +08:00
parent 24eaddbe0b
commit d64dcf6b01
2 changed files with 8 additions and 4 deletions

View File

@@ -354,7 +354,7 @@
"LinkMonitor": { "LinkMonitor": {
"name": "实时硬链接", "name": "实时硬链接",
"description": "监控目录文件变化,实时硬链接。", "description": "监控目录文件变化,实时硬链接。",
"version": "1.4", "version": "1.5",
"icon": "Linkace_C.png", "icon": "Linkace_C.png",
"author": "jxxghp", "author": "jxxghp",
"level": 1 "level": 1

View File

@@ -51,7 +51,7 @@ class LinkMonitor(_PluginBase):
# 插件图标 # 插件图标
plugin_icon = "Linkace_C.png" plugin_icon = "Linkace_C.png"
# 插件版本 # 插件版本
plugin_version = "1.4" plugin_version = "1.5"
# 插件作者 # 插件作者
plugin_author = "jxxghp" plugin_author = "jxxghp"
# 作者主页 # 作者主页
@@ -258,8 +258,12 @@ class LinkMonitor(_PluginBase):
:param target_path: 目标目录 :param target_path: 目标目录
:param transfer_type: 转移方式 :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(): if new_path.exists():
return True, "目标路径文件已存在" return True, "目标路径文件已存在"
else: else: