From 1e508cbcb26504f59e2674aac6e5f7c705fb88b3 Mon Sep 17 00:00:00 2001 From: thsrite Date: Fri, 18 Oct 2024 17:27:54 +0800 Subject: [PATCH] fix MediaSyncDel remove orgin file --- package.v2.json | 3 ++- plugins.v2/mediasyncdel/__init__.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.v2.json b/package.v2.json index bd01cce..6534df1 100644 --- a/package.v2.json +++ b/package.v2.json @@ -253,11 +253,12 @@ "name": "媒体文件同步删除", "description": "同步删除历史记录、源文件和下载任务。", "labels": "媒体库,文件整理", - "version": "1.8.1", + "version": "1.8.2", "icon": "mediasyncdel.png", "author": "thsrite", "level": 1, "history": { + "v1.8.2": "修复源文件删除", "v1.8.1": "适配v2多媒体服务器,移除日志方式", "v1.7": "修复重新整理被一并删除问题", "v1.6": "修复删除辅种", diff --git a/plugins.v2/mediasyncdel/__init__.py b/plugins.v2/mediasyncdel/__init__.py index bf00b13..4d24d36 100644 --- a/plugins.v2/mediasyncdel/__init__.py +++ b/plugins.v2/mediasyncdel/__init__.py @@ -1,3 +1,4 @@ +import json import os import time from pathlib import Path @@ -6,6 +7,7 @@ from typing import List, Tuple, Dict, Any, Optional from apscheduler.schedulers.background import BackgroundScheduler from app import schemas +from app.chain.storage import StorageChain from app.chain.transfer import TransferChain from app.core.config import settings from app.core.event import eventmanager, Event @@ -24,7 +26,7 @@ class MediaSyncDel(_PluginBase): # 插件图标 plugin_icon = "mediasyncdel.png" # 插件版本 - plugin_version = "1.8.1" + plugin_version = "1.8.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -742,6 +744,7 @@ class MediaSyncDel(_PluginBase): f"{media_type} {media_name} 未获取到可删除数据,请检查路径映射是否配置错误,请检查tmdbid获取是否正确") return + logger.info(f"获取到 {len(transfer_history)} 条转移记录,开始同步删除") # 开始删除 year = None del_torrent_hashs = [] @@ -749,6 +752,7 @@ class MediaSyncDel(_PluginBase): error_cnt = 0 image = 'https://emby.media/notificationicon.png' for transferhis in transfer_history: + logger.info(f"开始删除 {json.dumps(transferhis)}") title = transferhis.title if title not in media_name: logger.warn( @@ -764,8 +768,9 @@ class MediaSyncDel(_PluginBase): if self._del_source: # 1、直接删除源文件 if transferhis.src and Path(transferhis.src).suffix in settings.RMT_MEDIAEXT: - self._transferchain.delete_files(Path(transferhis.src)) - if transferhis.download_hash: + dest_fileitem = schemas.FileItem(**transferhis.dest_fileitem) + state = StorageChain().delete_file(dest_fileitem) + if state and transferhis.download_hash: try: # 2、判断种子是否被删除完 delete_flag, success_flag, handle_torrent_hashs = self.handle_torrent(