fix: return an error if the activation of tmp files fails (#255)

We want system-manager to return an error if the activation of tmp files fails.
This commit is contained in:
Jean-François Roche 2025-08-21 00:23:50 +02:00 committed by GitHub
parent c64d185d2c
commit ba09b781b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -82,18 +82,16 @@ pub fn activate(store_path: &StorePath, ephemeral: bool) -> Result<()> {
match etc_files::activate(store_path, old_state.file_tree, ephemeral) {
Ok(etc_tree) => {
log::info!("Activating tmp files...");
match tmp_files::activate(&etc_tree) {
Ok(_) => {
log::debug!("Successfully created tmp files");
}
Err(e) => {
let tmp_result = tmp_files::activate(&etc_tree);
if let Err(e) = &tmp_result {
log::error!("Error during activation of tmp files");
log::error!("{e}");
} else {
log::debug!("Successfully created tmp files");
}
};
log::info!("Activating systemd services...");
match services::activate(store_path, old_state.services, ephemeral) {
let final_state = match services::activate(store_path, old_state.services, ephemeral) {
Ok(services) => State {
file_tree: etc_tree,
services,
@ -105,20 +103,26 @@ pub fn activate(store_path: &StorePath, ephemeral: bool) -> Result<()> {
services: result,
}
}
};
final_state.write_to_file(state_file)?;
if let Err(e) = tmp_result {
return Err(e.into());
}
Ok(())
}
Err(ActivationError::WithPartialResult { result, source }) => {
log::error!("Error during activation: {source:?}");
State {
let final_state = State {
file_tree: result,
..old_state
}
}
}
.write_to_file(state_file)?;
};
final_state.write_to_file(state_file)?;
Ok(())
}
}
}
pub fn prepopulate(store_path: &StorePath, ephemeral: bool) -> Result<()> {
log::info!("Pre-populating system-manager profile: {store_path}");