in identity/aziot-identityd/src/identity.rs [1038:1075]
fn get_prev_modules(
prev_settings_path: &std::path::Path,
prev_device_info_path: &std::path::Path,
curr_hub_device_info: HubDeviceInfo,
) -> std::collections::BTreeSet<aziot_identity_common::ModuleId> {
if !prev_settings_path.exists() || !prev_device_info_path.exists() {
return Default::default();
}
let prev_hub_device_info = match HubDeviceInfo::new(prev_device_info_path) {
Ok(device_info) => device_info,
Err(err) => {
log::warn!("Ignoring invalid device info backup: {}", err);
return Default::default();
}
};
// Only consider the previous Hub modules if the current and previous Hub devices match.
if prev_hub_device_info != Some(curr_hub_device_info) {
return Default::default();
}
let prev_settings =
match crate::configext::load_file(prev_settings_path).map_err(Error::Internal) {
Ok(settings) => settings,
Err(err) => {
log::warn!("Ignoring invalid device settings backup: {}", err);
return Default::default();
}
};
let (_, prev_hub_modules, _) =
crate::configext::prepare_authorized_principals(&prev_settings.principal);
prev_hub_modules
}