Deduplicate Config reload logging

This commit is contained in:
Neshura 2023-12-18 11:24:02 +01:00
parent 080b0bf4d8
commit 5ba963305c
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -69,7 +69,10 @@ pub(crate) async fn run(data: Arc<RwLock<SharedData>>) {
Ok(data) => data,
Err(e) => panic!("{}", e),
};
write.messages.push(Message::Info("Config reloaded".to_string()));
let message = Message::Info("Config reloaded".to_string());
if !write.messages.contains(&message) {
write.messages.push(message);
};
}
}
@ -102,9 +105,12 @@ pub(crate) async fn run(data: Arc<RwLock<SharedData>>) {
continue
}
};
let message = Message::Info("Communities reloaded".to_string());
if !read.messages.contains(&message) {
drop(read);
let mut write = data.write().await;
write.messages.push(Message::Info("Communities reloaded".to_string()));
write.messages.push(message);
};
last_reload = Utc::now();
}
}
@ -199,10 +205,11 @@ async fn handle_series(
{
let read = data.read().await;
if read.post_history.check_for_post(series.slug.as_str(), post_part_info.as_string().as_str(), post_lemmy_info.title.as_str()) {
if !read.messages.contains(&Message::Info(format!("Skipping '{}' since already posted", post_lemmy_info.title))) {
let message = Message::Info(format!("Skipping '{}' since already posted", post_lemmy_info.title));
if !read.messages.contains(&message) {
drop(read);
let mut write = data.write().await;
write.messages.push(Message::Info(format!("Skipping '{}' since already posted", post_lemmy_info.title)));
write.messages.push(message);
};
post_list.remove(index);
continue