fix: 允许等待重试任务手动重新执行 (#70)

This commit is contained in:
chengma
2026-08-09 22:47:44 +08:00
parent 5df5398f32
commit a6c573a76a
6 changed files with 151 additions and 12 deletions
+31 -1
View File
@@ -608,7 +608,7 @@ class PDDTaskPageEvent(QObject):
self._stop_after_current(content)
@pyqtSlot(str, str, str)
def _on_collect_outcome(self, kind: str, message: str, _task_id: str) -> None:
def _on_collect_outcome(self, kind: str, message: str, task_id: str) -> None:
if self._closing:
return
self._reload()
@@ -622,6 +622,13 @@ class PDDTaskPageEvent(QObject):
)
elif kind == "result_pending":
self._on_claim_retryable_failed(message)
elif kind == "failed" and self._is_retry_wait_task(task_id):
content = (
f"自动获取:已停止 · 任务 {task_id} 重试已暂停;"
"请选择该任务点击“重新执行”,或重新启动获取任务"
)
self._show_retry_paused(content)
self._stop_after_current(content)
elif kind in {"manual_review", "failed"}:
self._show_claim_error("采集任务需要处理", message)
self._stop_after_current(message)
@@ -632,6 +639,29 @@ class PDDTaskPageEvent(QObject):
self._show_claim_error("自动获取已停止", content)
self._stop_after_current(content)
def _is_retry_wait_task(self, task_id: str) -> bool:
"""判断失败结果对应的任务是否仍可在本地重试。"""
if not task_id:
return False
try:
task = self._repository.get_task(task_id)
except Exception:
return False
return task is not None and task.status is TaskStatus.RETRY_WAIT
def _show_retry_paused(self, content: str) -> None:
"""用持久警告说明任务不会自行倒计时重试。"""
InfoBar.warning(
title="重试已暂停",
content=content,
isClosable=True,
duration=-1,
position=InfoBarPosition.TOP_RIGHT,
parent=self._page,
)
def _show_claim_error(self, title: str, content: str) -> None:
"""显示不会自动消失的可恢复错误,同时保留底部状态文字。"""