fix(dsh): atomically publish matching provider and key versions

This commit is contained in:
阿白叔 committed 2026-10-31 21:25:10 +08:00
1 parent dfbc14c081
commit da1806f745
6 files changed
+213 -12

No files matched your search

+12 -4
View File
@@ -8,7 +8,6 @@ from pathlib import Path
import subprocess
import sys
import time
import shutil
import hashlib
import traceback
@@ -16,6 +15,17 @@ REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO / 'src'))
def copy_provider_configuration(source: Path, destination: Path):
"""Copy one validated snapshot, including versioned or legacy DPAPI keys."""
from dx_productivity.dsh.provider_config import load_provider, save_provider
values = load_provider(source)
if not values:
raise ValueError('provider_configuration_missing')
save_provider(destination, base_url=values['DSH_API_BASE'],
models=json.loads(values['DX_DSH_MODELS']), default_model=values['DSH_MODEL'],
api_key=values['DSH_API_KEY'])
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', type=Path, default=REPO / 'build/dsh-native-desktop-verification')
@@ -39,9 +49,7 @@ def main():
path.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n', encoding='utf8')
source_hashes[str(path)] = hashlib.sha256(path.read_bytes()).hexdigest()
if args.provider_config:
(data / 'dsh').mkdir(parents=True, exist_ok=True)
for name in ('provider.json', 'provider-key.dpapi'):
shutil.copy2(args.provider_config / name, data / 'dsh' / name)
copy_provider_configuration(args.provider_config, data / 'dsh')
if args.incident:
(data / 'dsh').mkdir(parents=True, exist_ok=True)
(data / 'dsh/issue-config.json').write_text(json.dumps({'enabled': not args.outbox_only, 'acceptance': True}), encoding='utf8')