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,22 +243,23 @@ 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;
|
{
|
||||||
if post_series_config.pin_settings.pin_new_post_community && !read.config.protected_communities.contains(&post_series_config.name) {
|
let read = data.read().await;
|
||||||
let pinned_posts = lemmy.get_community_pinned(community_id).await?;
|
if post_series_config.pin_settings.pin_new_post_community && !read.config.protected_communities.contains(&post_series_config.name) {
|
||||||
if !pinned_posts.is_empty() {
|
let pinned_posts = lemmy.get_community_pinned(community_id).await?;
|
||||||
let community_pinned_post = &pinned_posts[0];
|
if !pinned_posts.is_empty() {
|
||||||
lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Community).await?;
|
let community_pinned_post = &pinned_posts[0];
|
||||||
|
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) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lemmy.pin(post_id, PostFeatureType::Community).await?;
|
|
||||||
}
|
|
||||||
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;
|
let read = data.read().await;
|
||||||
|
|
Loading…
Reference in a new issue