perf: replace automatic backups with manual backup reminders
This commit is contained in:
1 parent
7527800128
commit
c85696080d
26 files changed
+385
-102
No files matched your search
@@ -7,7 +7,8 @@ import re
|
||||
from uuid import uuid4
|
||||
|
||||
from .library_lock import LibraryLock, LibraryBusy
|
||||
from .scoped_manifest import ManifestScope, build_manifest, copy_verified, hash_file, scan_tree
|
||||
from .scoped_manifest import (ManifestScope, build_manifest, build_exclusive_library_manifest,
|
||||
copy_verified, hash_file, scan_tree)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -179,14 +180,14 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
|
||||
history.append({'stage': stage, 'time': datetime.now(timezone.utc).isoformat(), **details})
|
||||
if report:
|
||||
_write_json(report, {**asdict(request), 'stage': stage, 'status': 'RUNNING',
|
||||
'safe_to_continue': False, 'history': history})
|
||||
'safe_to_continue': False, 'history': history, 'backup_policy': 'manual'})
|
||||
if progress:
|
||||
progress({'stage': stage, 'block': request.name, 'operation': request.operation, **details})
|
||||
def finish(status, detail='', safe=True):
|
||||
result = ManagementResult(request.operation, request.library, request.name, request.partition,
|
||||
request.source, request.auto_verify, 'complete', status, safe, detail, report)
|
||||
if report:
|
||||
_write_json(report, {**asdict(result), 'history': history})
|
||||
_write_json(report, {**asdict(result), 'history': history, 'backup_policy': 'manual'})
|
||||
return result
|
||||
from .com_runtime import initialize_com, uninitialize_com
|
||||
initialized = initialize_com()
|
||||
@@ -202,7 +203,7 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
|
||||
raise ValueError('中心库必须为现有 LMC 文件。')
|
||||
evidence = Path(request.evidence_dir).resolve()
|
||||
if evidence.is_relative_to(library_root) or library_root.is_relative_to(evidence):
|
||||
raise ValueError('操作记录与备份必须位于目标中心库之外,且不能包含目标库。')
|
||||
raise ValueError('操作记录与暂存目录必须位于目标中心库之外,且不能包含目标库。')
|
||||
capability = adapter.capabilities().get(request.operation, Capability(False, '未验证的原生接口'))
|
||||
if not capability.supported:
|
||||
return finish('UNSUPPORTED', capability.reason)
|
||||
@@ -258,9 +259,9 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
|
||||
# Native/project owners must be idle before snapshot or mutation.
|
||||
idle_check(library, target_project, target_pcb)
|
||||
scope = ManifestScope.library(request.name, library.name)
|
||||
checkpoint('backup')
|
||||
original = copy_verified(library_root, root/'library-before', scope=scope, progress=progress)
|
||||
_write_json(root/'library-before-manifest.json', original)
|
||||
checkpoint('baseline')
|
||||
original = build_exclusive_library_manifest(library_root, scope=scope, progress=progress)
|
||||
_write_json(root/'library-baseline-manifest.json', original)
|
||||
staged = request
|
||||
identity = None
|
||||
if source:
|
||||
@@ -279,8 +280,8 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
|
||||
if not owner_safe or proof.identity is None:
|
||||
return finish('UPLOAD_FAILED', proof.detail, owner_safe)
|
||||
identity = proof.identity
|
||||
if build_manifest(library_root, scope=scope) != original:
|
||||
raise OSError('备份后中心库内容变化,停止写入。')
|
||||
if build_exclusive_library_manifest(library_root, scope=scope, progress=progress) != original:
|
||||
raise OSError('内容基线记录后中心库发生变化,停止写入。')
|
||||
if request.operation in ('remove', 'update'):
|
||||
checkpoint('native_remove')
|
||||
mutated = True; owner_safe = False
|
||||
@@ -299,7 +300,7 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
|
||||
removed = True
|
||||
checkpoint('removed')
|
||||
if request.operation == 'remove':
|
||||
return finish('REMOVED', '已备份并由原生操作移除,重新读取目录确认不存在。')
|
||||
return finish('REMOVED', '已由原生操作移除,重新读取目录确认不存在;应用未创建备份。')
|
||||
checkpoint('native_add')
|
||||
mutated = True; owner_safe = False
|
||||
native = adapter.add(staged, root/'add')
|
||||
|
||||
Reference in new issue
Block a user