@@ -82,15 +82,18 @@ impl DeploymentStatus {
82
82
/// a more native Rust structure.
83
83
fn get_deployments (
84
84
sysroot : & SysrootLock ,
85
- booted_deployment : & ostree:: Deployment ,
86
- booted : bool ,
85
+ booted_deployment : Option < & ostree:: Deployment > ,
86
+ booted_only : bool ,
87
87
) -> Result < Vec < ( ostree:: Deployment , DeploymentStatus ) > > {
88
+ let deployment_is_booted = |d : & ostree:: Deployment | -> bool {
89
+ booted_deployment. as_ref ( ) . map_or ( false , |b| d. equal ( b) )
90
+ } ;
88
91
sysroot
89
92
. deployments ( )
90
93
. into_iter ( )
91
- . filter ( |deployment| !booted || deployment . equal ( booted_deployment ) )
94
+ . filter ( |deployment| !booted_only || deployment_is_booted ( deployment ) )
92
95
. map ( |deployment| -> Result < _ > {
93
- let booted = deployment . equal ( booted_deployment ) ;
96
+ let booted = deployment_is_booted ( & deployment ) ;
94
97
let status = DeploymentStatus :: from_deployment ( & deployment, booted) ?;
95
98
Ok ( ( deployment, status) )
96
99
} )
@@ -101,9 +104,9 @@ fn get_deployments(
101
104
pub ( crate ) async fn status ( opts : super :: cli:: StatusOpts ) -> Result < ( ) > {
102
105
let sysroot = super :: cli:: get_locked_sysroot ( ) . await ?;
103
106
let repo = & sysroot. repo ( ) . unwrap ( ) ;
104
- let booted_deployment = & sysroot. require_booted_deployment ( ) ? ;
107
+ let booted_deployment = sysroot. booted_deployment ( ) ;
105
108
106
- let deployments = get_deployments ( & sysroot, booted_deployment, opts. booted ) ?;
109
+ let deployments = get_deployments ( & sysroot, booted_deployment. as_ref ( ) , opts. booted ) ?;
107
110
// If we're in JSON mode, then convert the ostree data into Rust-native
108
111
// structures that can be serialized.
109
112
if opts. json {
0 commit comments