mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
Update removelink to v2.2
This commit is contained in:
@@ -518,11 +518,12 @@
|
||||
"name": "清理硬链接",
|
||||
"description": "监控目录内文件被删除时,同步删除监控目录内所有和它硬链接的文件",
|
||||
"labels": "文件整理",
|
||||
"version": "2.0",
|
||||
"version": "2.2",
|
||||
"icon": "Ombi_A.png",
|
||||
"author": "DzAvril",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v2.2": "修复直接删除文件夹导致的插件崩溃的bug",
|
||||
"v2.1": "联动删除历史记录",
|
||||
"v2.0": "联动删除种子,需安装插件[下载器助手]并打开监听源文件事件",
|
||||
"v1.9": "增加清理刮削文件功能(beta)",
|
||||
|
||||
@@ -41,7 +41,10 @@ class FileMonitorHandler(FileSystemEventHandler):
|
||||
return
|
||||
# 新增文件记录
|
||||
with state_lock:
|
||||
self.sync.state_set[str(file_path)] = file_path.stat().st_ino
|
||||
try:
|
||||
self.sync.state_set[str(file_path)] = file_path.stat().st_ino
|
||||
except Exception as e:
|
||||
logger.error(f"新增文件记录失败:{str(e)}")
|
||||
|
||||
def on_moved(self, event):
|
||||
if event.is_directory:
|
||||
@@ -115,7 +118,7 @@ class RemoveLink(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "Ombi_A.png"
|
||||
# 插件版本
|
||||
plugin_version = "2.1"
|
||||
plugin_version = "2.2"
|
||||
# 插件作者
|
||||
plugin_author = "DzAvril"
|
||||
# 作者主页
|
||||
@@ -465,17 +468,19 @@ class RemoveLink(_PluginBase):
|
||||
# 文件所在目录已被删除则退出
|
||||
if not os.path.exists(path.parent):
|
||||
return
|
||||
# logger.info(f"清理刮削文件: {path}")
|
||||
if not path.suffix.lower() in [
|
||||
".jpg",
|
||||
".nfo",
|
||||
]:
|
||||
# 清理与path相关的刮削文件
|
||||
name_prefix = path.stem
|
||||
for file in path.parent.iterdir():
|
||||
if file.name.startswith(name_prefix):
|
||||
file.unlink()
|
||||
logger.info(f"删除刮削文件:{file}")
|
||||
try:
|
||||
if not path.suffix.lower() in [
|
||||
".jpg",
|
||||
".nfo",
|
||||
]:
|
||||
# 清理与path相关的刮削文件
|
||||
name_prefix = path.stem
|
||||
for file in path.parent.iterdir():
|
||||
if file.name.startswith(name_prefix):
|
||||
file.unlink()
|
||||
logger.info(f"删除刮削文件:{file}")
|
||||
except Exception as e:
|
||||
logger.error(f"清理刮削文件发生错误:{str(e)}.")
|
||||
# 清理空目录
|
||||
self.delete_empty_folders(path)
|
||||
|
||||
@@ -510,23 +515,30 @@ class RemoveLink(_PluginBase):
|
||||
break
|
||||
|
||||
# 若目录下只剩刮削文件,则清空文件夹
|
||||
if self.scrape_files_left(parent_path):
|
||||
# 清除目录下所有文件
|
||||
for file in parent_path.iterdir():
|
||||
file.unlink()
|
||||
logger.info(f"删除刮削文件:{file}")
|
||||
try:
|
||||
if self.scrape_files_left(parent_path):
|
||||
# 清除目录下所有文件
|
||||
for file in parent_path.iterdir():
|
||||
file.unlink()
|
||||
logger.info(f"删除刮削文件:{file}")
|
||||
except Exception as e:
|
||||
logger.error(f"清理刮削文件发生错误:{str(e)}.")
|
||||
|
||||
try:
|
||||
if not os.listdir(parent_path):
|
||||
os.rmdir(parent_path)
|
||||
logger.info(f"清理空目录:{parent_path}")
|
||||
if self._notify:
|
||||
self.post_message(
|
||||
mtype=NotificationType.SiteMessage,
|
||||
title=f"【清理硬链接】",
|
||||
text=f"清理空文件夹:[{parent_path}]\n",
|
||||
)
|
||||
else:
|
||||
break
|
||||
except Exception as e:
|
||||
logger.error(f"清理空目录发生错误:{str(e)}")
|
||||
|
||||
if not os.listdir(parent_path):
|
||||
os.rmdir(parent_path)
|
||||
logger.info(f"清理空目录:{parent_path}")
|
||||
if self._notify:
|
||||
self.post_message(
|
||||
mtype=NotificationType.SiteMessage,
|
||||
title=f"【清理硬链接】",
|
||||
text=f"清理空文件夹:[{parent_path}]\n",
|
||||
)
|
||||
else:
|
||||
break
|
||||
# 更新路径为父目录,准备下一轮检查
|
||||
path = parent_path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user