diff --git a/src/main.rs b/src/main.rs index 2211915..a4a99d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -167,6 +167,20 @@ where fn check_previous_rollback() -> Result { log::debug!("Checking journalctl for previous rollback attempts..."); + // Use systemd's first-boot detection to skip the rollback check on first boot. + // This is more reliable than journalctl --list-boots, which would also skip + // on systems with non-persistent journald storage. + let first_boot_check = Command::new("systemd-analyze") + .arg("condition") + .arg("ConditionFirstBoot=yes") + .output() + .context("Failed to execute 'systemd-analyze condition ConditionFirstBoot=yes'")?; + + if first_boot_check.status.success() { + log::debug!("First boot detected, skipping rollback check"); + return Ok(false); + } + let output = Command::new("journalctl") .arg("-b") .arg("-1") @@ -186,8 +200,7 @@ fn check_previous_rollback() -> Result { return Ok(false); } - let journal_output = - String::from_utf8(output.stdout).context("Failed to parse journalctl output as UTF-8")?; + let journal_output = String::from_utf8_lossy(&output.stdout); if journal_output.trim().is_empty() { log::debug!("No rollback service logs found in previous boot");