Fix write lock while read lock still present

This commit is contained in:
Neshura 2023-12-18 23:33:14 +01:00
parent b14d37e01c
commit f0e1bca08e
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -243,6 +243,7 @@ async fn handle_series(
let post_id = lemmy.post(post_data).await?;
{
let read = data.read().await;
if post_series_config.pin_settings.pin_new_post_community && !read.config.protected_communities.contains(&post_series_config.name) {
let pinned_posts = lemmy.get_community_pinned(community_id).await?;
@ -251,14 +252,14 @@ async fn handle_series(
lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Community).await?;
}
lemmy.pin(post_id, PostFeatureType::Community).await?;
}
else if read.config.protected_communities.contains(&post_series_config.name) {
} else if read.config.protected_communities.contains(&post_series_config.name) {
let message = Message::Warning(format!("Community '{}' for Series '{}' is protected. Is this intended?", &post_series_config.name, series.slug));
if !read.messages.contains(&message) {
drop(read);
let mut write = data.write().await;
write.messages.push(message);
};
}
}
}
let read = data.read().await;