mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-13 17:52:28 +08:00
优化移动模式下的种子和残留目录删除逻辑
This commit is contained in:
@@ -498,18 +498,22 @@ class TransferChain(ChainBase, metaclass=Singleton):
|
||||
if transferinfo.transfer_type in ["move"]:
|
||||
# 所有成功的业务
|
||||
tasks = self.jobview.success_tasks(task.mediainfo, task.meta.begin_season)
|
||||
# 记录已处理的种子hash
|
||||
processed_hashes = set()
|
||||
storagechain = StorageChain()
|
||||
for t in tasks:
|
||||
# 下载器hash
|
||||
if t.download_hash and t.download_hash not in processed_hashes:
|
||||
processed_hashes.add(t.download_hash)
|
||||
if self.remove_torrents(t.download_hash, downloader=t.downloader):
|
||||
logger.info(f"移动模式删除种子成功:{t.download_hash} ")
|
||||
# 删除残留目录
|
||||
if t.fileitem:
|
||||
storagechain.delete_media_file(t.fileitem, delete_self=False)
|
||||
if t.download_hash:
|
||||
# 检查种子目录下是否还有有效媒体文件
|
||||
if t.fileitem:
|
||||
remain_files = storagechain.list_files(t.fileitem, recursion=True)
|
||||
has_media = any(
|
||||
f.extension and f.extension.lower() in [ext.lstrip('.') for ext in self.all_exts]
|
||||
for f in remain_files if f.type == "file")
|
||||
if not has_media:
|
||||
if self.remove_torrents(t.download_hash, downloader=t.downloader):
|
||||
logger.info(f"移动模式删除种子成功:{t.download_hash} ")
|
||||
storagechain.delete_media_file(t.fileitem, delete_self=False)
|
||||
else:
|
||||
logger.info(f"目录 {t.fileitem.path} 还有未整理的媒体文件,暂不删除种子和残留目录")
|
||||
# 整理完成且有成功的任务时
|
||||
if self.jobview.is_finished(task):
|
||||
__do_finished()
|
||||
|
||||
Reference in New Issue
Block a user