@@ -21,7 +21,7 @@ use anyhow::Result;
21
21
use async_std:: stream:: StreamExt ;
22
22
use async_std:: sync:: Arc ;
23
23
use futures_util:: FutureExt ;
24
- use log:: { info, warn} ;
24
+ use log:: { error , info, warn} ;
25
25
use serde:: { Deserialize , Serialize } ;
26
26
27
27
use super :: systemd:: { Service , ServiceAction } ;
@@ -47,15 +47,31 @@ use installer::InstallerProxy;
47
47
#[ cfg( not( feature = "demo_mode" ) ) ]
48
48
mod poller;
49
49
50
+ #[ cfg( not( feature = "demo_mode" ) ) ]
51
+ use poller:: PollerProxy ;
52
+
50
53
#[ cfg( feature = "demo_mode" ) ]
51
54
mod imports {
52
55
pub ( super ) const CHANNELS_DIR : & str = "demo_files/usr/share/tacd/update_channels" ;
56
+
57
+ pub ( super ) struct PollerProxy < ' a > {
58
+ _dummy : & ' a ( ) ,
59
+ }
60
+
61
+ impl PollerProxy < ' _ > {
62
+ pub async fn new < C > ( _conn : C ) -> Option < Self > {
63
+ Some ( Self { _dummy : & ( ) } )
64
+ }
65
+
66
+ pub async fn poll ( & self ) -> zbus:: Result < ( ) > {
67
+ Ok ( ( ) )
68
+ }
69
+ }
53
70
}
54
71
55
72
#[ cfg( not( feature = "demo_mode" ) ) ]
56
73
mod imports {
57
74
pub ( super ) use anyhow:: bail;
58
- pub ( super ) use log:: error;
59
75
60
76
pub ( super ) const CHANNELS_DIR : & str = "/usr/share/tacd/update_channels" ;
61
77
}
@@ -186,11 +202,14 @@ fn would_reboot_into_other_slot(slot_status: &SlotStatus, primary: Option<String
186
202
}
187
203
188
204
async fn channel_list_update_task (
205
+ conn : Arc < Connection > ,
189
206
reload : Arc < Topic < bool > > ,
190
207
enable_polling : Arc < Topic < bool > > ,
191
208
channels : Arc < Topic < Channels > > ,
192
209
rauc_service : Service ,
193
210
) -> Result < ( ) > {
211
+ let poller = PollerProxy :: new ( & conn) . await . unwrap ( ) ;
212
+
194
213
let ( reload_stream, _) = reload. subscribe_unbounded ( ) ;
195
214
let ( mut enable_polling_stream, _) = enable_polling. subscribe_unbounded ( ) ;
196
215
@@ -254,6 +273,14 @@ async fn channel_list_update_task(
254
273
} else {
255
274
info ! ( "Config is up to date. Will not reload." ) ;
256
275
}
276
+
277
+ if enable_polling {
278
+ info ! ( "Trigger a poll" ) ;
279
+
280
+ if let Err ( err) = poller. poll ( ) . await {
281
+ error ! ( "Failed to poll for updates: {err}" ) ;
282
+ }
283
+ }
257
284
}
258
285
}
259
286
@@ -297,6 +324,7 @@ impl Rauc {
297
324
wtb. spawn_task (
298
325
"rauc-channel-list-update" ,
299
326
channel_list_update_task (
327
+ Arc :: new ( Connection ) ,
300
328
inst. reload . clone ( ) ,
301
329
inst. enable_polling . clone ( ) ,
302
330
inst. channels . clone ( ) ,
@@ -505,6 +533,7 @@ impl Rauc {
505
533
wtb. spawn_task (
506
534
"rauc-channel-list-update" ,
507
535
channel_list_update_task (
536
+ conn. clone ( ) ,
508
537
inst. reload . clone ( ) ,
509
538
inst. enable_polling . clone ( ) ,
510
539
inst. channels . clone ( ) ,
0 commit comments