fix: respect rejected batch import receipts

This commit is contained in:
阿白叔 committed 2026-11-18 09:36:48 +08:00
1 parent eda9403d94
commit de16bbdfa1
3 files changed
+18 -1

No files matched your search

+2
View File
@@ -8,6 +8,8 @@
批量导入后,任务内保留这个相对路径作为工程名称,列表、历史和报告中都能区分不同目录里的同名工程。
批量名称沿用任务库的 256 字符上限;相对路径超过上限时该项显示导入失败,可缩短目录层级或使用“添加工程对”单独添加。不会把任务库拒收误报成导入成功。
勾选后点“导入所选”,只建立前后只读副本,随后回到任务点击“开始全部”或“校验所选”。单项导入失败后继续其他项,失败原因保留在状态提示中;取消或关闭导入窗口时保留已导入项,未处理项可继续选择导入。磁盘空间或存储故障会中断整批并保留已导入项。此窗口不阻止新建其他校验任务。
“开始全部”处理当前任务中当时待校验/中断的工程;筛选不会缩小这个范围。“校验所选”和“重校验”明确处理所选工程当前版本。运行期间后到的新项或新版本留待下次开始。校验只读副本,不会重新换料或自动换脚。
@@ -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
@@ -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