Skip to content

Commit 67d4fed

Browse files
committed
dbus: rauc: update_channels: add a concept of a single primary channel
RAUC native update polling only supports a single update channel. Prepare for that by adding a concept of a primary update channel. The primary channel is the first enabled one with the highest priority by channel file name.
1 parent f8bb62b commit 67d4fed

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,8 @@ components:
11321132
type: integer
11331133
enabled:
11341134
type: boolean
1135+
primary:
1136+
type: boolean
11351137
bundle:
11361138
type: object
11371139
properties:

src/dbus/rauc/update_channels.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub struct Channel {
4848
pub url: String,
4949
pub polling_interval: Option<Duration>,
5050
pub enabled: bool,
51+
pub primary: bool,
5152
pub bundle: Option<UpstreamBundle>,
5253
}
5354

@@ -110,6 +111,7 @@ impl Channel {
110111
url: channel_file.url.trim().to_string(),
111112
polling_interval,
112113
enabled: false,
114+
primary: false,
113115
bundle: None,
114116
};
115117

@@ -147,13 +149,21 @@ impl Channels {
147149

148150
let mut channels: Vec<Channel> = Vec::new();
149151

152+
let mut have_primary = false;
153+
150154
for dir_entry in dir_entries {
151-
let channel = Channel::from_file(&dir_entry.path())?;
155+
let mut channel = Channel::from_file(&dir_entry.path())?;
152156

153157
if channels.iter().any(|ch| ch.name == channel.name) {
154158
bail!("Encountered duplicate channel name \"{}\"", channel.name);
155159
}
156160

161+
// There can only be one primary channel.
162+
// If multiple channels are enabled the primary one is the one with
163+
// the highest precedence.
164+
channel.primary = channel.enabled && !have_primary;
165+
have_primary |= channel.primary;
166+
157167
channels.push(channel);
158168
}
159169

0 commit comments

Comments
 (0)