From aa64df080d51969168b6ab949d673384576631f3 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 12 Mar 2021 19:22:17 +0000 Subject: [PATCH] daemon: Fix serialization of unlocked state It turns out there's a naming clash between `to_string()` here in Rust *and* introspection is incorrectly associating the method with `ostree::Deployment` because of the naming prefix. --- rust/src/daemon.rs | 8 +++++++- tests/kolainst/nondestructive/misc.sh | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rust/src/daemon.rs b/rust/src/daemon.rs index dd9fe088..3d863512 100644 --- a/rust/src/daemon.rs +++ b/rust/src/daemon.rs @@ -70,7 +70,13 @@ pub(crate) fn deployment_populate_variant( dict.insert("pinned", &deployment.is_pinned()); let unlocked = deployment.get_unlocked(); - dict.insert("unlocked", &unlocked.to_string()); + // Unwrap safety: This always returns a value + dict.insert( + "unlocked", + &ostree::Deployment::unlocked_state_to_string(unlocked) + .unwrap() + .as_str(), + ); Ok(()) } diff --git a/tests/kolainst/nondestructive/misc.sh b/tests/kolainst/nondestructive/misc.sh index f1ac9904..657c7528 100755 --- a/tests/kolainst/nondestructive/misc.sh +++ b/tests/kolainst/nondestructive/misc.sh @@ -69,9 +69,11 @@ else echo "Missing ${wrapdir}; cliwrap not enabled" fi -# StateRoot is only in --verbose +# StateRoot is only in --verbose, also verify we're not showing +# unlocked. rpm-ostree status > status.txt assert_not_file_has_content status.txt StateRoot: +assert_not_file_has_content status.txt Unlocked: rpm-ostree status -v > status.txt assert_file_has_content status.txt StateRoot: echo "ok status text"