Skip to content

Commit b64ce44

Browse files
committed
Add storage actions
1 parent 2ea9e8f commit b64ce44

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

rust/agama-manager/src/service.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@ impl Service {
8484
}
8585
}
8686

87+
async fn configure_l10n(&self, config: api::l10n::SystemConfig) -> Result<(), Error> {
88+
self.l10n
89+
.call(l10n::message::SetSystem::new(config.clone()))
90+
.await?;
91+
if let Some(locale) = config.locale {
92+
self.storage
93+
.cast(storage::message::SetLocale::new(locale.as_str()))?;
94+
}
95+
Ok(())
96+
}
97+
98+
async fn activate_storage(&self) -> Result<(), Error> {
99+
self.storage.call(storage::message::Activate).await?;
100+
Ok(())
101+
}
102+
103+
async fn probe_storage(&self) -> Result<(), Error> {
104+
self.storage.call(storage::message::Probe).await?;
105+
Ok(())
106+
}
107+
87108
async fn install(&mut self) -> Result<(), Error> {
88109
self.state = State::Installing;
89110
self.events.send(Event::StateChanged)?;
@@ -102,17 +123,6 @@ impl Service {
102123
self.events.send(Event::StateChanged)?;
103124
Ok(())
104125
}
105-
106-
async fn configure_l10n(&self, config: api::l10n::SystemConfig) -> Result<(), Error> {
107-
self.l10n
108-
.call(l10n::message::SetSystem::new(config.clone()))
109-
.await?;
110-
if let Some(locale) = config.locale {
111-
self.storage
112-
.cast(storage::message::SetLocale::new(locale.as_str()))?;
113-
}
114-
Ok(())
115-
}
116126
}
117127

118128
impl Actor for Service {
@@ -250,6 +260,12 @@ impl MessageHandler<message::RunAction> for Service {
250260
Action::ConfigureL10n(config) => {
251261
self.configure_l10n(config).await?;
252262
}
263+
Action::ActivateStorage => {
264+
self.activate_storage().await?;
265+
}
266+
Action::ProbeStorage => {
267+
self.probe_storage().await?;
268+
}
253269
Action::Install => {
254270
self.install().await?;
255271
}

rust/agama-utils/src/api/action.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ use serde::Deserialize;
2323

2424
#[derive(Debug, Deserialize, utoipa::ToSchema)]
2525
pub enum Action {
26+
#[serde(rename = "activateStorage")]
27+
ActivateStorage,
28+
#[serde(rename = "probeStorage")]
29+
ProbeStorage,
2630
#[serde(rename = "configureL10n")]
2731
ConfigureL10n(l10n::SystemConfig),
2832
#[serde(rename = "install")]

0 commit comments

Comments
 (0)