feat: polish Shopee update checks

This commit is contained in:
chengma
2026-07-01 14:30:49 +08:00
parent cc277366ed
commit 84b35f1cdc
12 changed files with 301 additions and 83 deletions
+29
View File
@@ -678,6 +678,35 @@ def set_generated(task_id, new_title, new_cover_path, path=None, conn=None) -> N
(new_title, new_cover_path, now, now, int(task_id)),
)
def update_generated_title(task_id, new_title, path=None, conn=None) -> None:
"""Update a generated title manually without touching Shopee or local cover files."""
title = str(new_title or "").strip()
if not title:
raise DbError("新标题不能为空")
with _connection(conn, path) as database:
task = get_task(task_id, conn=database)
if task is None:
raise DbError(f"任务不存在或批次已删除: {task_id}")
if int(task.committed or 0) == 1 or task.stage == "applied":
raise DbError("已提交线上商品不能在本地直接修改新标题")
if task.stage != "generated":
raise DbError("只有已生成且未提交线上的任务可以修改新标题")
if task.status == "running":
raise DbError("任务正在运行,不能修改新标题")
now = _now()
with database:
database.execute(
"""
UPDATE tasks
SET new_title = ?,
status = 'pending',
last_error = NULL,
updated_at = ?
WHERE id = ?
""",
(title, now, int(task_id)),
)
def set_applied(task_id, committed, error=None, path=None, conn=None) -> None:
now = _now()