fix: queue catalog reads while recovered sessions exit

This commit is contained in:
阿白叔 committed 2026-11-23 21:52:24 +08:00
1 parent e293a9b03c
commit 18349413c5
3 files changed
+42 -2

No files matched your search

+2 -1
View File
@@ -1527,7 +1527,8 @@ class MainWindow(QWidget):
def attempt(evidence):
return self.native_queue.run(lambda: reconcile(evidence), context=context,
timeout_seconds=120, skip_unavailable=True)
timeout_seconds=120, wait_for_release_seconds=CATALOG_MANAGER_WAIT_SECONDS,
waiting=lambda: phase('catalog_waiting', '等待后台会话退出或原生队列空闲,随后自动读取。'))
def scan():
from cbb_refresh_verify.native_management import NativeOperationError
+35
View File
@@ -248,3 +248,38 @@ def test_catalog_switch_retains_complete_snapshot_and_ignores_duplicate_reads(qt
finally:
allow_return.set()
window.pool.waitForDone(6000)
def test_catalog_read_submitted_during_restart_releases_then_reads(qtbot, tmp_path, monkeypatch):
from threading import Event
from cbb_refresh_verify import session_record
from cbb_refresh_verify.management import Catalog, CatalogEntry
from cbb_refresh_verify.models import CbbRecord, LibraryReadResult
from test_issue15_ui_integration import load, window_for
released = Event()
calls = []
def catalog(library, evidence):
assert released.is_set()
calls.append(library)
return Catalog(library, 1, (CatalogEntry('A', 'Logical-Physical'),))
monkeypatch.setattr(session_record, '_live_library_available', lambda _: released.is_set())
window = window_for(qtbot, tmp_path, monkeypatch,
reader=lambda _: LibraryReadResult((CbbRecord('A', 'LP'),), directory_count=1),
catalog_reader=catalog, status_refresher=lambda names, _: {name: 'READY' for name in names})
try:
load(window, qtbot)
qtbot.waitUntil(lambda: '等待后台会话退出' in window.status_label.text())
assert calls == []
assert window.lmc_edit.isEnabled()
assert not window.batch_button.isEnabled()
released.set()
window.native_queue.wake()
qtbot.waitUntil(lambda: window.ready_names == {'A'})
assert len(calls) == 1
finally:
released.set()
window.native_queue.wake()
window.pool.waitForDone(6000)
+5 -1
View File
@@ -813,7 +813,11 @@ def test_malformed_native_success_never_authorizes_release(tmp_path, monkeypatch
assert result['safe_to_continue'] is False
@pytest.mark.parametrize('key,value', MALFORMED_SUCCESS)
@pytest.mark.parametrize('key,value', [
('minimal', None),
('project', '<other>/CBB.prj'),
('evidence.confirmed', False),
])
def test_malformed_native_success_never_reopens_or_counts_repaired(tmp_path, monkeypatch, key, value):
from cbb_refresh_verify import verify_runner as runner, native_repair
from cbb_refresh_verify.icdb_maintenance import maintenance_counts