mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 16:36:53 +08:00
fix: 重新整理时忽略旧下载哈希 (#6154)
This commit is contained in:
@@ -270,7 +270,8 @@ def manual_transfer(
|
|||||||
# 强制转移
|
# 强制转移
|
||||||
force = True
|
force = True
|
||||||
downloader = history.downloader
|
downloader = history.downloader
|
||||||
download_hash = history.download_hash
|
# 仅复用历史识别信息时才传入旧 Hash,否则由当前文件路径重新匹配下载记录。
|
||||||
|
download_hash = history.download_hash if transer_item.from_history else None
|
||||||
if history.status and ("move" in history.mode):
|
if history.status and ("move" in history.mode):
|
||||||
# 重新整理成功的转移,则使用成功的 dest 做 in_path
|
# 重新整理成功的转移,则使用成功的 dest 做 in_path
|
||||||
src_fileitems = [FileItem(**history.dest_fileitem)]
|
src_fileitems = [FileItem(**history.dest_fileitem)]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from app.schemas import EpisodeFormatRecommendItem, ManualTransferItem, Transfer
|
|||||||
|
|
||||||
|
|
||||||
def test_manual_transfer_from_history_preserves_download_context(monkeypatch):
|
def test_manual_transfer_from_history_preserves_download_context(monkeypatch):
|
||||||
|
"""复用历史识别信息时应传递原下载上下文。"""
|
||||||
history = SimpleNamespace(
|
history = SimpleNamespace(
|
||||||
status=0,
|
status=0,
|
||||||
mode="copy",
|
mode="copy",
|
||||||
@@ -53,6 +54,60 @@ def test_manual_transfer_from_history_preserves_download_context(monkeypatch):
|
|||||||
assert captured["season"] == 1
|
assert captured["season"] == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_manual_transfer_without_history_recognition_ignores_old_hash(monkeypatch):
|
||||||
|
"""从历史重新识别时应忽略旧 Hash,但保留下载器上下文。"""
|
||||||
|
history = SimpleNamespace(
|
||||||
|
status=0,
|
||||||
|
mode="copy",
|
||||||
|
src_fileitem={
|
||||||
|
"storage": "local",
|
||||||
|
"path": "/downloads/test.mkv",
|
||||||
|
"name": "test.mkv",
|
||||||
|
"type": "file",
|
||||||
|
},
|
||||||
|
dest_fileitem=None,
|
||||||
|
downloader="qbittorrent",
|
||||||
|
download_hash="polluted-hash",
|
||||||
|
type="电视剧",
|
||||||
|
tmdbid="100",
|
||||||
|
doubanid="200",
|
||||||
|
seasons="S01",
|
||||||
|
episodes="E01",
|
||||||
|
episode_group="WEB-DL",
|
||||||
|
)
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_get(_db, logid):
|
||||||
|
"""返回受污染的历史记录。"""
|
||||||
|
assert logid == 1
|
||||||
|
return history
|
||||||
|
|
||||||
|
class FakeTransferChain:
|
||||||
|
"""记录 API 传入整理链的参数。"""
|
||||||
|
|
||||||
|
def manual_transfer(self, **kwargs):
|
||||||
|
"""记录手动整理参数。"""
|
||||||
|
captured.update(kwargs)
|
||||||
|
return True, ""
|
||||||
|
|
||||||
|
monkeypatch.setattr("app.api.endpoints.transfer.TransferHistory.get", fake_get)
|
||||||
|
monkeypatch.setattr("app.api.endpoints.transfer.TransferChain", FakeTransferChain)
|
||||||
|
|
||||||
|
resp = manual_transfer(
|
||||||
|
transer_item=ManualTransferItem(logid=1, from_history=False),
|
||||||
|
background=True,
|
||||||
|
db=object(),
|
||||||
|
_="token",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert resp.success is True
|
||||||
|
assert captured["downloader"] == "qbittorrent"
|
||||||
|
assert captured["download_hash"] is None
|
||||||
|
assert captured["tmdbid"] is None
|
||||||
|
assert captured["doubanid"] is None
|
||||||
|
assert captured["episode_group"] is None
|
||||||
|
|
||||||
|
|
||||||
def test_manual_transfer_from_history_passes_old_dest_cleanup_to_chain(monkeypatch):
|
def test_manual_transfer_from_history_passes_old_dest_cleanup_to_chain(monkeypatch):
|
||||||
history = SimpleNamespace(
|
history = SimpleNamespace(
|
||||||
status=0,
|
status=0,
|
||||||
|
|||||||
Reference in New Issue
Block a user