fix: scope release proofs and bind PCB opening consent
This commit is contained in:
1 parent
42d0cebc54
commit
466f400514
33 files changed
+1358
-61
No files matched your search
@@ -940,6 +940,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
last_activity_key = None
|
||||
phase = DialogPhase.PCB_STARTING
|
||||
restore_controller = None
|
||||
open_controller = None
|
||||
dialog_agent = None
|
||||
latest_snapshots = ()
|
||||
if dialog_supervisor_factory is None:
|
||||
@@ -1038,6 +1039,17 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
dialog_result = dialog_supervisor.poll()
|
||||
else:
|
||||
dialog_result = dialog_supervisor.poll()
|
||||
if (version_prompt is not None and consent is None and dialog_agent is not None
|
||||
and not request.diagnostic_only and not request.native_lm_verify
|
||||
and dialog_result.error_code == 'DATABASE_RECOVERY_REQUIRED'
|
||||
and dialog_result.snapshot is not None):
|
||||
from .pcb_open_consent import OpenController, exact_prompt
|
||||
if exact_prompt(dialog_result.snapshot):
|
||||
if open_controller is None:
|
||||
open_controller = OpenController(job)
|
||||
dialog_result = open_controller.handle(dialog_result.snapshot, dialog_result.observed_snapshots,
|
||||
target_pid=target_pid, launcher_pid=launcher_pid, worker_pid=process.pid,
|
||||
show=version_prompt, perform=dialog_supervisor.backend.perform)
|
||||
if (consent is not None and dialog_agent is not None
|
||||
and dialog_result.error_code == 'DATABASE_RECOVERY_REQUIRED'
|
||||
and dialog_result.snapshot is not None and exact_prompt(dialog_result.snapshot)):
|
||||
@@ -1050,11 +1062,11 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
from .dialog_rules import archive_version_choice
|
||||
choice_path = archive_version_choice(dialog_result.snapshot, root)
|
||||
dialog_result = replace(dialog_result, detail=dialog_result.detail + f'\n版本候选与原生窗口证据:{choice_path}')
|
||||
if (version_prompt is not None and consent is not None and dialog_agent is not None
|
||||
if (version_prompt is not None and not request.diagnostic_only and dialog_agent is not None
|
||||
and dialog_result.snapshot.hwnd in {int(h) for h in process.desktop.EnumDesktopWindows()}):
|
||||
from .pcb_restore_prompt import RestoreController
|
||||
if restore_controller is None:
|
||||
restore_controller = RestoreController(job)
|
||||
restore_controller = RestoreController(job, user_open=consent is None)
|
||||
dialog_result = restore_controller.handle(dialog_result.snapshot,
|
||||
dialog_result.observed_snapshots, target_pid=target_pid, launcher_pid=launcher_pid,
|
||||
worker_pid=process.pid, companion_pids=tuple(process.companion_pids),
|
||||
@@ -1089,7 +1101,8 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
# recovery checks for remaining native database clients.
|
||||
_stop_worker(process, timeout=40)
|
||||
return finish(VerifyResult(
|
||||
'FAIL',
|
||||
'CANCELLED' if dialog_result.error_code == 'USER_CANCELLED' else
|
||||
'SKIPPED' if dialog_result.error_code == 'PCB_OPEN_SKIPPED' else 'FAIL',
|
||||
stderr=f'{dialog_result.error_code}: {dialog_result.detail}',
|
||||
error_stage=phase.value,
|
||||
safe_to_continue=False,
|
||||
@@ -1291,7 +1304,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
return finish(result)
|
||||
|
||||
|
||||
def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=None):
|
||||
def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=None, item_executor=None):
|
||||
"""Run serially and stop when database/session safety is unconfirmed."""
|
||||
if max_workers != 1:
|
||||
raise ValueError('Only serial Verify is supported for the shared Library Manager session')
|
||||
@@ -1308,10 +1321,18 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
|
||||
result = VerifyResult('SKIPPED', stderr='同库原生会话尚未释放,未启动新的写入')
|
||||
else:
|
||||
try:
|
||||
result = verifier(request)
|
||||
def execute():
|
||||
result = verifier(request)
|
||||
if not result.safe_to_continue:
|
||||
from .operation_lifecycle import recheck_failed_release
|
||||
result = recheck_failed_release(request.lmc_file, request.block_name, result)
|
||||
return result
|
||||
result = item_executor(request, execute) if item_executor is not None else execute()
|
||||
except Exception as error:
|
||||
from .operation_queue import QueueCancelled
|
||||
# An unexpected exception cannot establish database safety.
|
||||
result = VerifyResult('FAIL', stderr=str(error), safe_to_continue=False)
|
||||
result = VerifyResult('CANCELLED' if isinstance(error, QueueCancelled) else 'FAIL',
|
||||
stderr=str(error), safe_to_continue=isinstance(error, QueueCancelled))
|
||||
results.append(result)
|
||||
# Never start another writer after an unconfirmed native shutdown.
|
||||
if not result.safe_to_continue:
|
||||
|
||||
Reference in new issue
Block a user