@@ -117,13 +117,17 @@ impl From<(i32, String, i32)> for Progress {
117
117
#[ derive( Serialize , Deserialize , Clone ) ]
118
118
#[ serde( from = "UpdateRequestDe" ) ]
119
119
pub struct UpdateRequest {
120
+ pub manifest_hash : Option < String > ,
120
121
pub url : Option < String > ,
121
122
}
122
123
123
124
#[ derive( Deserialize ) ]
124
125
#[ serde( untagged) ]
125
126
enum UpdateRequestDe {
126
- UrlObject { url : Option < String > } ,
127
+ UrlAndHash {
128
+ manifest_hash : Option < String > ,
129
+ url : Option < String > ,
130
+ } ,
127
131
UrlOnly ( String ) ,
128
132
}
129
133
@@ -132,8 +136,11 @@ impl From<UpdateRequestDe> for UpdateRequest {
132
136
// Provide API backward compatibility by allowing either just a String
133
137
// as argument or a map with url and manifest hash inside.
134
138
match de {
135
- UpdateRequestDe :: UrlObject { url } => Self { url } ,
136
- UpdateRequestDe :: UrlOnly ( url) => Self { url : Some ( url) } ,
139
+ UpdateRequestDe :: UrlAndHash { manifest_hash, url } => Self { manifest_hash, url } ,
140
+ UpdateRequestDe :: UrlOnly ( url) => Self {
141
+ manifest_hash : None ,
142
+ url : Some ( url) ,
143
+ } ,
137
144
}
138
145
}
139
146
}
@@ -579,7 +586,14 @@ impl Rauc {
579
586
// Poor-mans validation. It feels wrong to let someone point to any
580
587
// file on the TAC from the web interface.
581
588
if url. starts_with ( "http://" ) || url. starts_with ( "https://" ) {
582
- let args = HashMap :: new ( ) ;
589
+ let manifest_hash: Option < zbus:: zvariant:: Value > =
590
+ update_request. manifest_hash . map ( |mh| mh. into ( ) ) ;
591
+
592
+ let mut args = HashMap :: new ( ) ;
593
+
594
+ if let Some ( manifest_hash) = & manifest_hash {
595
+ args. insert ( "require-manifest-hash" , manifest_hash) ;
596
+ }
583
597
584
598
if let Err ( e) = proxy. install_bundle ( & url, args) . await {
585
599
error ! ( "Failed to install bundle: {}" , e) ;
0 commit comments