Skip to content

Commit 0a757e4

Browse files
committed
dbus: rauc: trigger a single poll for updates after reloading the daemon
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent c71040c commit 0a757e4

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/dbus/rauc.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use anyhow::Result;
2121
use async_std::stream::StreamExt;
2222
use async_std::sync::Arc;
2323
use futures_util::FutureExt;
24-
use log::{info, warn};
24+
use log::{error, info, warn};
2525
use serde::{Deserialize, Serialize};
2626

2727
use super::systemd::{Service, ServiceAction};
@@ -47,15 +47,31 @@ use installer::InstallerProxy;
4747
#[cfg(not(feature = "demo_mode"))]
4848
mod poller;
4949

50+
#[cfg(not(feature = "demo_mode"))]
51+
use poller::PollerProxy;
52+
5053
#[cfg(feature = "demo_mode")]
5154
mod imports {
5255
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+
}
5370
}
5471

5572
#[cfg(not(feature = "demo_mode"))]
5673
mod imports {
5774
pub(super) use anyhow::bail;
58-
pub(super) use log::error;
5975

6076
pub(super) const CHANNELS_DIR: &str = "/usr/share/tacd/update_channels";
6177
}
@@ -186,11 +202,14 @@ fn would_reboot_into_other_slot(slot_status: &SlotStatus, primary: Option<String
186202
}
187203

188204
async fn channel_list_update_task(
205+
conn: Arc<Connection>,
189206
reload: Arc<Topic<bool>>,
190207
enable_polling: Arc<Topic<bool>>,
191208
channels: Arc<Topic<Channels>>,
192209
rauc_service: Service,
193210
) -> Result<()> {
211+
let poller = PollerProxy::new(&conn).await.unwrap();
212+
194213
let (reload_stream, _) = reload.subscribe_unbounded();
195214
let (mut enable_polling_stream, _) = enable_polling.subscribe_unbounded();
196215

@@ -254,6 +273,14 @@ async fn channel_list_update_task(
254273
} else {
255274
info!("Config is up to date. Will not reload.");
256275
}
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+
}
257284
}
258285
}
259286

@@ -297,6 +324,7 @@ impl Rauc {
297324
wtb.spawn_task(
298325
"rauc-channel-list-update",
299326
channel_list_update_task(
327+
Arc::new(Connection),
300328
inst.reload.clone(),
301329
inst.enable_polling.clone(),
302330
inst.channels.clone(),
@@ -505,6 +533,7 @@ impl Rauc {
505533
wtb.spawn_task(
506534
"rauc-channel-list-update",
507535
channel_list_update_task(
536+
conn.clone(),
508537
inst.reload.clone(),
509538
inst.enable_polling.clone(),
510539
inst.channels.clone(),

0 commit comments

Comments
 (0)