feat: publish official resources atomically

Fixes #9

Fixes #11
This commit is contained in:
2026-07-14 00:10:39 +08:00
parent 45aba2fb2b
commit 2ff99ae9e3
10 changed files with 1055 additions and 63 deletions
@@ -229,6 +229,27 @@ fn official_update_first_run_pulls_without_pre_audit() {
assert!(events
.iter()
.any(|event| { event.stage == "decision" && event.message.contains("首次拉取=true") }));
let published = report.published_version_path.as_ref().unwrap();
assert!(published.exists());
assert!(report
.staging_path
.as_ref()
.is_some_and(|path| !path.exists()));
assert!(config.output_root.join("current").exists());
assert!(fs::symlink_metadata(config.output_root.join("current"))
.unwrap()
.file_type()
.is_symlink());
assert_eq!(
config
.output_root
.join("official-download-manifest.json")
.exists(),
false
);
assert!(published.join("official-download-manifest.json").exists());
assert!(published.join("official-sync-snapshot.json").exists());
}
#[test]
@@ -262,6 +283,11 @@ fn official_update_second_run_audits_existing_resources_before_reuse() {
assert!(events.iter().any(|event| {
event.stage == "decision" && event.message.contains("首次拉取=false")
}));
assert!(config.output_root.join("current").exists());
assert!(fs::symlink_metadata(config.output_root.join("current"))
.unwrap()
.file_type()
.is_symlink());
}
struct TestHarness {