fix: prove prewrite cancellation and bound recovery metadata lifetime

This commit is contained in:
阿白叔 committed 2026-11-17 12:45:59 +08:00
1 parent 32dcd80d1e
commit 906cfc06be
14 files changed
+659 -60

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
"""Real application close while one disposable metadata boundary is held."""
from pathlib import Path
import sys,time
from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QApplication
from cbb_refresh_verify import scoped_manifest as manifest
from cbb_refresh_verify.operation_queue import check_active
from cbb_refresh_verify.ui.main_window import MainWindow
root=Path(sys.argv[1]);mode=sys.argv[2]
source=root/'source';source.mkdir()
(source/('one.log' if mode=='copy' else 'one.dat')).write_bytes(b'isolated fixture')
def held():
(root/'entered').touch()
while not (root/'release').exists():time.sleep(.02)
def hash_file(path):
held()
return manifest.hash_file(path)
if mode=='copy':
original=manifest.shutil.copy2
def copy_file(*args,**kwargs):
held()
return original(*args,**kwargs)
manifest.shutil.copy2=copy_file
def action():
if mode=='hash':manifest.build_manifest(source,hash_function=hash_file)
else:manifest.copy_verified(source,root/'partial-copy',hash_function=hash_file)
check_active()
(root/'late-dispatch').touch()
app=QApplication([])
window=MainWindow(reader=lambda _:None,data_root=root/'data');window.show()
job=window._new_job('management',library=root/'library.lmc')
window._start(action,lambda _:None,queued=False,job=job)
def close_when_entered():
if (root/'entered').exists():window.close()
else:QTimer.singleShot(20,close_when_entered)
QTimer.singleShot(20,close_when_entered)
code=app.exec()
(root/'main-returning').touch()
raise SystemExit(code)