@@ -114,6 +114,30 @@ impl From<(i32, String, i32)> for Progress {
114
114
}
115
115
}
116
116
117
+ #[ derive( Serialize , Deserialize , Clone ) ]
118
+ #[ serde( from = "UpdateRequestDe" ) ]
119
+ pub struct UpdateRequest {
120
+ pub url : Option < String > ,
121
+ }
122
+
123
+ #[ derive( Deserialize ) ]
124
+ #[ serde( untagged) ]
125
+ enum UpdateRequestDe {
126
+ UrlObject { url : Option < String > } ,
127
+ UrlOnly ( String ) ,
128
+ }
129
+
130
+ impl From < UpdateRequestDe > for UpdateRequest {
131
+ fn from ( de : UpdateRequestDe ) -> Self {
132
+ // Provide API backward compatibility by allowing either just a String
133
+ // as argument or a map with url and manifest hash inside.
134
+ match de {
135
+ UpdateRequestDe :: UrlObject { url } => Self { url } ,
136
+ UpdateRequestDe :: UrlOnly ( url) => Self { url : Some ( url) } ,
137
+ }
138
+ }
139
+ }
140
+
117
141
type SlotStatus = HashMap < String , HashMap < String , String > > ;
118
142
119
143
pub struct Rauc {
@@ -123,7 +147,7 @@ pub struct Rauc {
123
147
#[ cfg_attr( feature = "demo_mode" , allow( dead_code) ) ]
124
148
pub primary : Arc < Topic < String > > ,
125
149
pub last_error : Arc < Topic < String > > ,
126
- pub install : Arc < Topic < String > > ,
150
+ pub install : Arc < Topic < UpdateRequest > > ,
127
151
pub channels : Arc < Topic < Channels > > ,
128
152
pub reload : Arc < Topic < bool > > ,
129
153
pub should_reboot : Arc < Topic < bool > > ,
@@ -336,7 +360,7 @@ impl Rauc {
336
360
slot_status : bb. topic_ro ( "/v1/tac/update/slots" , None ) ,
337
361
primary : bb. topic_ro ( "/v1/tac/update/primary" , None ) ,
338
362
last_error : bb. topic_ro ( "/v1/tac/update/last_error" , None ) ,
339
- install : bb. topic_wo ( "/v1/tac/update/install" , Some ( "" . to_string ( ) ) ) ,
363
+ install : bb. topic_wo ( "/v1/tac/update/install" , None ) ,
340
364
channels : bb. topic_ro ( "/v1/tac/update/channels" , None ) ,
341
365
reload : bb. topic_wo ( "/v1/tac/update/channels/reload" , Some ( true ) ) ,
342
366
should_reboot : bb. topic_ro ( "/v1/tac/update/should_reboot" , Some ( false ) ) ,
@@ -546,7 +570,12 @@ impl Rauc {
546
570
wtb. spawn_task ( "rauc-forward-install" , async move {
547
571
let proxy = InstallerProxy :: new ( & conn_task) . await . unwrap ( ) ;
548
572
549
- while let Some ( url) = install_stream. next ( ) . await {
573
+ while let Some ( update_request) = install_stream. next ( ) . await {
574
+ let url = match update_request. url {
575
+ Some ( url) => url,
576
+ None => continue ,
577
+ } ;
578
+
550
579
// Poor-mans validation. It feels wrong to let someone point to any
551
580
// file on the TAC from the web interface.
552
581
if url. starts_with ( "http://" ) || url. starts_with ( "https://" ) {
0 commit comments