Skip to content

Commit 2e771cf

Browse files
committed
add more helper and fix function names
1 parent 8c6b351 commit 2e771cf

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

crates/lib/src/cli.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ pub(crate) fn require_root(is_container: bool) -> Result<()> {
754754
Ok(())
755755
}
756756

757-
/// Check if a deployment can perform a soft reboot
758-
fn can_perform_soft_reboot(deployment: Option<&crate::spec::BootEntry>) -> bool {
757+
/// Check if a deployment has soft reboot capability
758+
fn has_soft_reboot_capability(deployment: Option<&crate::spec::BootEntry>) -> bool {
759759
deployment.map(|d| d.soft_reboot_capable).unwrap_or(false)
760760
}
761761

@@ -907,7 +907,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
907907
if staged_unchanged {
908908
println!("Staged update present, not changed.");
909909
if opts.queue_soft_reboot {
910-
if can_perform_soft_reboot(host.status.staged.as_ref()) {
910+
if has_soft_reboot_capability(host.status.staged.as_ref()) {
911911
soft_reboot_staged(sysroot)?;
912912
}
913913
}
@@ -936,7 +936,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
936936
// At this point we have new staged deployment and the host definition has changed.
937937
// We need the updated host status before we check if we can prepare the soft-reboot.
938938
let updated_host = crate::status::get_status(sysroot, Some(&booted_deployment))?.1;
939-
if can_perform_soft_reboot(updated_host.status.staged.as_ref()) {
939+
if has_soft_reboot_capability(updated_host.status.staged.as_ref()) {
940940
soft_reboot_staged(sysroot)?;
941941
}
942942
}
@@ -1020,7 +1020,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
10201020
// At this point we have staged the deployment and the host definition has changed.
10211021
// We need the updated host status before we check if we can prepare the soft-reboot.
10221022
let updated_host = crate::status::get_status(sysroot, Some(&booted_deployment))?.1;
1023-
if can_perform_soft_reboot(updated_host.status.staged.as_ref()) {
1023+
if has_soft_reboot_capability(updated_host.status.staged.as_ref()) {
10241024
soft_reboot_staged(sysroot)?;
10251025
}
10261026
}
@@ -1042,7 +1042,7 @@ async fn rollback(opts: RollbackOpts) -> Result<()> {
10421042
// Get status after the rollback is done to check soft-reboot capability
10431043
let host = crate::status::get_status_require_booted(sysroot)?.2;
10441044

1045-
if can_perform_soft_reboot(host.status.rollback.as_ref()) {
1045+
if has_soft_reboot_capability(host.status.rollback.as_ref()) {
10461046
println!("Rollback deployment is soft-reboot capable, preparing for soft-reboot...");
10471047

10481048
let deployments_list = sysroot.deployments();

crates/lib/src/status.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ impl From<ImageReference> for OstreeImageReference {
8686
}
8787
}
8888

89+
/// Check if a deployment has soft reboot capability
90+
fn has_soft_reboot_capability(sysroot: &Storage, deployment: &ostree::Deployment) -> bool {
91+
ostree_ext::systemd_has_soft_reboot() && sysroot.deployment_can_soft_reboot(deployment)
92+
}
93+
8994
/// Parse an ostree origin file (a keyfile) and extract the targeted
9095
/// container image reference.
9196
fn get_image_origin(origin: &glib::KeyFile) -> Result<Option<OstreeImageReference>> {
@@ -144,8 +149,7 @@ fn boot_entry_from_deployment(
144149
(None, CachedImageStatus::default(), false)
145150
};
146151

147-
let soft_reboot_capable =
148-
ostree_ext::systemd_has_soft_reboot() && sysroot.deployment_can_soft_reboot(deployment);
152+
let soft_reboot_capable = has_soft_reboot_capability(sysroot, deployment);
149153

150154
let r = BootEntry {
151155
image,

0 commit comments

Comments
 (0)