mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-30 11:54:50 +08:00
fix(transfer): look up torrent by hash without builtin tag filter (#7031)
This commit is contained in:
@@ -744,7 +744,8 @@ class TransferSettlementOwner(_TransferOwnerBase):
|
||||
) -> bool:
|
||||
"""确认种子下载完成;查询失败或缺失时记录原因,不把未知状态当作完成。"""
|
||||
try:
|
||||
torrents = self.list_torrents(hashs=download_hash, downloader=downloader)
|
||||
# Hash 已唯一定位任务;工作流自定义标签或调整 TORRENT_TAG 后的任务也要能回写。
|
||||
torrents = self.list_torrents(hashs=download_hash, downloader=downloader, include_all_tags=True)
|
||||
if not torrents:
|
||||
logger.warning(
|
||||
f"下载器 {downloader} 中未查询到种子 {download_hash},无法回写已整理标签,请检查种子是否已移除或历史关联是否正确"
|
||||
|
||||
@@ -141,6 +141,23 @@ def test_mark_tags_when_torrent_completed():
|
||||
assert completed == [{"hashs": "hash1", "downloader": "qbittorrent"}]
|
||||
|
||||
|
||||
def test_mark_queries_torrent_by_hash_regardless_of_builtin_tag():
|
||||
"""按 Hash 回写时不得受 TORRENT_TAG 过滤,否则工作流自定义标签的任务永远无法打上已整理标签。"""
|
||||
chain = _make_chain()
|
||||
completed = []
|
||||
queries = []
|
||||
chain.transfer_completed = lambda **kwargs: completed.append(kwargs)
|
||||
chain.list_torrents = lambda **kwargs: queries.append(kwargs) or (
|
||||
[SimpleNamespace(progress=100)] if kwargs.get("include_all_tags") else []
|
||||
)
|
||||
_finish_task(chain, _make_task(1, "hash1", "qbittorrent"))
|
||||
|
||||
_mark(chain, "hash1", "qbittorrent")
|
||||
|
||||
assert queries == [{"hashs": "hash1", "downloader": "qbittorrent", "include_all_tags": True}]
|
||||
assert completed == [{"hashs": "hash1", "downloader": "qbittorrent"}]
|
||||
|
||||
|
||||
def test_mark_short_circuits_downloader_query_when_jobview_not_done():
|
||||
"""作业视图还有未结束任务时,不应产生任何下载器查询。"""
|
||||
chain = _make_chain()
|
||||
|
||||
Reference in New Issue
Block a user