Properly release lock on user header...

This commit is contained in:
Natsu Kagami 2024-06-20 17:16:19 +02:00
parent 8e7b2b75e8
commit fdeba634f4
Signed by: nki
GPG key ID: 55A032EB38B49ADB
2 changed files with 6 additions and 4 deletions

View file

@ -197,6 +197,7 @@ pub async fn mania(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
get_user(ctx, &env, msg, args, Mode::Mania).await get_user(ctx, &env, msg, args, Mode::Mania).await
} }
#[derive(Debug, Clone)]
pub(crate) struct BeatmapWithMode(pub Beatmap, pub Mode); pub(crate) struct BeatmapWithMode(pub Beatmap, pub Mode);
impl BeatmapWithMode { impl BeatmapWithMode {

View file

@ -73,12 +73,13 @@ impl Client {
/// Fetch the user header. /// Fetch the user header.
pub async fn user_header(&self, id: u64) -> Result<Option<UserHeader>, Error> { pub async fn user_header(&self, id: u64) -> Result<Option<UserHeader>, Error> {
Ok( Ok({
match self.user_header_cache.lock().await.get(&id).cloned() { let v = self.user_header_cache.lock().await.get(&id).cloned();
match v {
Some(v) => v, Some(v) => v,
None => self.user(UserID::ID(id), |f| f).await?.map(|v| v.into()), None => self.user(UserID::ID(id), |f| f).await?.map(|v| v.into()),
}, }
) })
} }
pub async fn scores( pub async fn scores(