a superseded activation leaves the hook and gc to the newer one
Signed-off-by: dawn <90008@klbr.net>
1247 unmodified linesExpand all1248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831247 unmodified linesExpand all last_tested().ends_with("/active.conf"), "a rollback tests it all" );}
#[test]fn a_superseded_activation_leaves_gc_to_the_newer_one() { let env = setup_test_env(); assert!(knot_static(&env.config, ["generate"]).status.success()); let first = get_only_generation_dir(&env.output); let first_id = first.file_name().unwrap().to_str().unwrap().to_string(); assert!( knot_static(&env.config, ["activate", &first_id]) .status .success() ); let abandoned = env.output.join("generations").join(".building-abandoned"); std::fs::create_dir_all(&abandoned).unwrap(); let older = "0".repeat(64); let after = |generation: &str| { let ran = knot_static(&env.config, ["after-activation", generation, "--at", "1"]); assert!( ran.status.success(), "{}", String::from_utf8_lossy(&ran.stderr) ); };
after(&older); assert!( abandoned.exists(), "a superseded activation collects nothing" ); after(&first_id); assert!(!abandoned.exists(), "the current one collects");}442 unmodified linesExpand all44344444544644744744844945045145245345445545645745845946046145746246346446545946646746846947071 unmodified lines442 unmodified linesExpand all crate::pds::publish_all(config.clone(), changed_repos).await; }}
/// a newer activation starts its own hook, so an older one only collects/// a newer activation starts its own hook and collects after it, so a superseded one does neitherpub fn after_activation( config: &ValidatedConfig, generation: &str, previous: Option<&str>, activated_at_unix: u64,) -> anyhow::Result<()> { let superseded = || publish::current_generation(&config.output_root).as_deref() != Some(generation); if superseded() { return Ok(()); } let generations = config.output_root.join("generations"); let hook = { let _output_lock = crate::output::lock(&config.output_root)?; let current = publish::current_generation(&config.output_root); if superseded() { return Ok(()); } let hook = match &config.activate.site_hook { Some(_) if current.as_deref() == Some(generation) => { Some(_) => { let generation_dir = generations.join(generation); let manifest = GenerationManifest::load(&generation_dir)?; let previous = previous.and_then(|previous| { GenerationManifest::load(&generations.join(previous)).ok()71 unmodified lines