From de16bbdfa141994d69b305688994f88b0fc3a22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Wed, 18 Nov 2026 09:36:48 +0800 Subject: [PATCH] fix: respect rejected batch import receipts --- docs/user/independent-verification.md | 2 ++ .../trial_task_center/verification/batch_import.py | 8 +++++++- tests/v1_1/test_verification_batch_import.py | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/user/independent-verification.md b/docs/user/independent-verification.md index db82f98..9e2db68 100644 --- a/docs/user/independent-verification.md +++ b/docs/user/independent-verification.md @@ -8,6 +8,8 @@ 批量导入后,任务内保留这个相对路径作为工程名称,列表、历史和报告中都能区分不同目录里的同名工程。 +批量名称沿用任务库的 256 字符上限;相对路径超过上限时该项显示导入失败,可缩短目录层级或使用“添加工程对”单独添加。不会把任务库拒收误报成导入成功。 + 勾选后点“导入所选”,只建立前后只读副本,随后回到任务点击“开始全部”或“校验所选”。单项导入失败后继续其他项,失败原因保留在状态提示中;取消或关闭导入窗口时保留已导入项,未处理项可继续选择导入。磁盘空间或存储故障会中断整批并保留已导入项。此窗口不阻止新建其他校验任务。 “开始全部”处理当前任务中当时待校验/中断的工程;筛选不会缩小这个范围。“校验所选”和“重校验”明确处理所选工程当前版本。运行期间后到的新项或新版本留待下次开始。校验只读副本,不会重新换料或自动换脚。 diff --git a/src/dx_productivity/trial_task_center/verification/batch_import.py b/src/dx_productivity/trial_task_center/verification/batch_import.py index e8e9a3f..48c1bfe 100644 --- a/src/dx_productivity/trial_task_center/verification/batch_import.py +++ b/src/dx_productivity/trial_task_center/verification/batch_import.py @@ -56,7 +56,13 @@ def import_pairs(service, task_id, pairs, *, request_id, stop_event, on_progress receipt = service.import_pair(task_id, before, after, request_id='batch-row:'+digest([request_id, index, before, after]), stop_event=stop_event, display_name=names[index]) - row.update(status='imported', receipt=receipt) + if receipt['accepted'] or receipt['duplicates']: + row.update(status='imported', receipt=receipt) + else: + reason = ';'.join(r['reason'] for r in receipt['rejected']) or '工程未被任务接收。' + if names[index] is not None and len(names[index])>256: + reason = '相对路径超过256字符,请缩短目录层级或使用“添加工程对”。' + row.update(status='failed', reason=reason, receipt=receipt) except TaskCenterError as error: if error.code == 'operation_cancelled': result['cancelled'] = True diff --git a/tests/v1_1/test_verification_batch_import.py b/tests/v1_1/test_verification_batch_import.py index 0cf2ae7..7825be6 100644 --- a/tests/v1_1/test_verification_batch_import.py +++ b/tests/v1_1/test_verification_batch_import.py @@ -94,3 +94,12 @@ def test_cancelled_request_cannot_be_reused_for_different_input(service, tmp_pat with pytest.raises(TaskCenterError) as error: service.import_pairs(task, (), request_id='batch', stop_event=Event()) assert error.value.code == 'verification_conflict' + + +def test_rejected_display_name_is_not_reported_as_imported(service, tmp_path): + pairs = ((project(tmp_path/'before', 'A'), project(tmp_path/'after', 'A')),) + task = service.create_task('拒绝', request_id='create')['task_id'] + result = service.import_pairs(task, pairs, request_id='batch', stop_event=Event(), display_names=('x'*257,)) + assert result['rows'][0]['status'] == 'failed' + assert result['rows'][0]['reason'] + assert service.repo.connection.execute('SELECT COUNT(*) FROM verification_items').fetchone()[0] == 0