Verify real CBB BOM imports and handle first-open native database updates
This commit is contained in:
1 parent
a332e7bd59
commit
1b39d802bd
9 files changed
+504
-9
No files matched your search
@@ -81,13 +81,17 @@ def preview_batch(service, task_id, path):
|
||||
if key not in grouped:
|
||||
continue
|
||||
baseline = tuple(store.list_target_plan(task.task_id))
|
||||
if baseline:
|
||||
inventory = tuple(row.target for row in baseline)
|
||||
else:
|
||||
parts = tuple(dict.fromkeys(record.old for record in grouped[key]))
|
||||
preparer = service.for_project_task(task.task_id)._quick_run_preparer
|
||||
inventory = tuple(preparer.collect_inventory(project.path, parts))
|
||||
rows = match_bom_records(baseline or tuple(TargetPlanRow(target) for target in inventory), grouped[key])
|
||||
try:
|
||||
if baseline:
|
||||
inventory = tuple(row.target for row in baseline)
|
||||
else:
|
||||
parts = tuple(dict.fromkeys(record.old for record in grouped[key]))
|
||||
preparer = service.for_project_task(task.task_id)._quick_run_preparer
|
||||
inventory = tuple(preparer.collect_inventory(project.path, parts))
|
||||
rows = match_bom_records(baseline or tuple(TargetPlanRow(target) for target in inventory), grouped[key])
|
||||
except TaskCenterError as error:
|
||||
raise TaskCenterError(error.code, f'工程「{task.name}」({project.path}):{error.message}',
|
||||
error_id=error.error_id, traceback_detail=error.traceback_detail) from error
|
||||
projects.append(BomProjectPreview(task.task_id, project.path, baseline, inventory, rows))
|
||||
return BomBatchPreview(task_id, _identity(scope), tuple(projects))
|
||||
|
||||
|
||||
@@ -133,7 +133,8 @@ class DiscoveryCache:
|
||||
# final database hash still invalidates later cache reuse.
|
||||
previous = None
|
||||
previous_design = None
|
||||
for attempt in range(2):
|
||||
attempt, limit = 0, 2
|
||||
while attempt < limit:
|
||||
if attempt:
|
||||
before = project_fingerprint(project, self.data_root)
|
||||
discovery = loader()
|
||||
@@ -144,9 +145,14 @@ class DiscoveryCache:
|
||||
design = _without_runtime_database(after)
|
||||
if previous is not None and previous == discovery and previous_design == design:
|
||||
break
|
||||
# First-open normalization can precede the two stable
|
||||
# inventory reads. Allow one extra pass only in that case.
|
||||
if attempt == 1 and previous is None:
|
||||
limit = 3
|
||||
previous, previous_design = deepcopy(discovery), design
|
||||
else:
|
||||
previous = previous_design = None
|
||||
attempt += 1
|
||||
else:
|
||||
raise TaskCenterError("quick_run_sheet_discovery",
|
||||
"project contents changed or could not be verified during discovery; retry read-only discovery")
|
||||
|
||||
Reference in new issue
Block a user