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
@@ -1,4 +1,4 @@
|
||||
"""Backed-up, single-attempt recovery through the installed native tool."""
|
||||
"""Single-attempt recovery through the installed native tool."""
|
||||
from dataclasses import dataclass
|
||||
import hashlib
|
||||
import json
|
||||
@@ -48,6 +48,19 @@ def _hash(path):
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def check_repair_access(target):
|
||||
"""Preserve the former pre-copy ownership checks without copying data."""
|
||||
import win32con, win32file, pywintypes
|
||||
from .scoped_manifest import scan_tree
|
||||
scan_tree(target.project.parent) # Reject links before native traversal.
|
||||
try:
|
||||
handle = win32file.CreateFile(str(target.database/'icdb.dat'), win32con.GENERIC_READ, 0, None,
|
||||
win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None)
|
||||
except pywintypes.error as error:
|
||||
raise OSError(f'REPAIR_DATABASE_IN_USE: 无法独占读取数据库:{error}') from error
|
||||
handle.Close()
|
||||
|
||||
|
||||
def backup_project(target, destination):
|
||||
"""Keep every original file, holding icdb.dat exclusively during the copy."""
|
||||
import win32con, win32file, pywintypes
|
||||
@@ -130,7 +143,7 @@ def attempt_recovery(request, diagnosis, evidence_root, *, progress=None):
|
||||
target = select_repair_target(request, diagnosis)
|
||||
if progress:
|
||||
progress({'stage': 'native_repair_start', 'block': request.block_name,
|
||||
'detail': '正在备份并尝试原生数据库修复', 'project': str(target.project)})
|
||||
'detail': '正在核对占用并尝试原生数据库修复;应用不自动备份', 'project': str(target.project)})
|
||||
from .mentor_adapter import pcb_processes, _process_details
|
||||
if pcb_processes() or _process_details('LibraryManager.exe'):
|
||||
raise ValueError('REPAIR_DATABASE_IN_USE: 原生 PCB/Library Manager 会话尚未退出')
|
||||
|
||||
Reference in new issue
Block a user