perf(execution): use native-host full snapshots for owned batches
This commit is contained in:
1 parent
2f6060dfe3
commit
81f34683ea
9 files changed
+261
-14
No files matched your search
@@ -21,6 +21,7 @@ from uuid import uuid4
|
||||
from .errors import TaskCenterError
|
||||
from .models import ProjectRecord, ProjectStatus, RuleRecord
|
||||
from .retention import maintain_quick_run_storage, rotate_text_log
|
||||
from .worker_runtime import copy_worker_script
|
||||
|
||||
|
||||
DONE_STATES = frozenset({"restored_ok", "saved_ok", "no_match"})
|
||||
@@ -119,7 +120,7 @@ class QuickRunPreparer:
|
||||
log_path = root / "quick-part-replace.log"
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
_assert_no_pending_status(status_path, log_path)
|
||||
shutil.copyfile(source, script_path)
|
||||
copy_worker_script(source, script_path)
|
||||
if sheet_targets is not None:
|
||||
manifest_path = root / "sheets.tsv"
|
||||
manifest_path.write_text(_sheet_manifest_text(selected_projects, sheet_targets), encoding="utf-8", newline="")
|
||||
@@ -254,7 +255,7 @@ class QuickRunPreparer:
|
||||
)
|
||||
source = self._required_script_source()
|
||||
if source.resolve() != handoff.script_path.resolve():
|
||||
shutil.copyfile(source, handoff.script_path)
|
||||
copy_worker_script(source, handoff.script_path)
|
||||
commands = _read_commands(handoff.command_path)
|
||||
command_options = _read_command_options(handoff.command_path)
|
||||
statuses = _read_status_details(handoff.status_path)
|
||||
@@ -373,7 +374,7 @@ class QuickRunPreparer:
|
||||
else:
|
||||
source = self._required_script_source()
|
||||
if source.resolve() != handoff.script_path.resolve():
|
||||
shutil.copyfile(source, handoff.script_path)
|
||||
copy_worker_script(source, handoff.script_path)
|
||||
commands = _read_commands(handoff.command_path)
|
||||
before = _read_status_details(handoff.status_path)
|
||||
selected_command = _next_unfinished_command(commands, before)
|
||||
|
||||
@@ -176,7 +176,8 @@ def recover(preparer, task_id, projects, rules, *, copy_part_number_to_value=Fal
|
||||
if _recovery_hashes(audit / 'evidence-before') != evidence_before or _recovery_hashes(root) != evidence_before:
|
||||
raise TaskCenterError('quick_run_recovery', '备份期间执行证据变化,已停止。')
|
||||
script = worker / 'QuickPartReplace.vbs'
|
||||
shutil.copyfile(preparer._required_script_source(), script)
|
||||
from .worker_runtime import copy_worker_script
|
||||
copy_worker_script(preparer._required_script_source(), script)
|
||||
shutil.copyfile(snapshot, worker / snapshot.name)
|
||||
(worker / 'recovery.request').write_text(job_id, encoding='ascii')
|
||||
option_fields = (selected_mode, selected_custom_value, '1' if selected_sync_nc else '0', selected_base_mode)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
"""Compose the worker with its optional read-only native snapshot adapter."""
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
|
||||
def copy_worker_script(source: Path, destination: Path) -> None:
|
||||
source, destination = Path(source), Path(destination)
|
||||
if source.resolve() == destination.resolve():
|
||||
return
|
||||
shutil.copyfile(source, destination)
|
||||
adapter = source.with_name('NativeSnapshotReader.vbs')
|
||||
if adapter.is_file():
|
||||
with destination.open('ab') as output:
|
||||
output.write(b'\r\n')
|
||||
output.write(adapter.read_bytes())
|
||||
Reference in new issue
Block a user