Skip to content

Commit 570834c

Browse files
committed
fix deleted host import
1 parent df9d32e commit 570834c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/import/ops.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ async fn get_user_profile(
112112
if let Ok(user_profile) = internal::user::user_profile_by_user_id(&connection, user_id) {
113113
Ok(user_profile)
114114
} else {
115-
cis_client
115+
warn!("no profile for {} → fetching", user_id);
116+
let profile = cis_client
116117
.clone()
117118
.get_user_by(user_id, &GetBy::UserId, None)
118-
.await
119-
.and_then(|p| p.try_into())
119+
.await?;
120+
internal::user::update_user_cache(connection, &profile)?;
121+
profile.try_into()
120122
}
121123
}
122124

@@ -193,9 +195,11 @@ pub async fn import_member(
193195
let host = if member.host.is_empty() {
194196
User::default()
195197
} else {
196-
let host_profile = get_user_profile(connection, &member.host, cis_client.clone()).await?;
197-
User {
198-
user_uuid: host_profile.user_uuid,
198+
match get_user_profile(connection, &member.host, cis_client.clone()).await {
199+
Ok(p) => User {
200+
user_uuid: p.user_uuid,
201+
},
202+
_ => User::default(),
199203
}
200204
};
201205
internal::member::add_to_group(connection, group_name, &host, &user, expiration)?;

0 commit comments

Comments
 (0)