Fix write lock while read lock still present
This commit is contained in:
parent
b14d37e01c
commit
f0e1bca08e
1 changed files with 16 additions and 15 deletions
|
@ -243,6 +243,7 @@ async fn handle_series(
|
||||||
|
|
||||||
let post_id = lemmy.post(post_data).await?;
|
let post_id = lemmy.post(post_data).await?;
|
||||||
|
|
||||||
|
{
|
||||||
let read = data.read().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) {
|
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?;
|
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.unpin(community_pinned_post.post.id, PostFeatureType::Community).await?;
|
||||||
}
|
}
|
||||||
lemmy.pin(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));
|
let message = Message::Warning(format!("Community '{}' for Series '{}' is protected. Is this intended?", &post_series_config.name, series.slug));
|
||||||
if !read.messages.contains(&message) {
|
if !read.messages.contains(&message) {
|
||||||
drop(read);
|
drop(read);
|
||||||
let mut write = data.write().await;
|
let mut write = data.write().await;
|
||||||
write.messages.push(message);
|
write.messages.push(message);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let read = data.read().await;
|
let read = data.read().await;
|
||||||
|
|
Loading…
Reference in a new issue