Private
Public Access
1
0

Try to resolve daemon hang when changing settings

This commit is contained in:
2025-06-16 19:06:35 -07:00
parent 45aaf55804
commit 9d591dffc5
2 changed files with 9 additions and 7 deletions

View File

@@ -251,13 +251,15 @@ impl Daemon {
}
Event::UpdateSettings(settings, reply) => {
let previous_server_url = self.get_settings().await.unwrap_or_default().server_url;
let previous_settings = self.get_settings().await.unwrap_or_default();
let previous_server_url = previous_settings.server_url;
self.update_settings(&settings).await.unwrap_or_else(|e| {
log::error!(target: target::SETTINGS, "Failed to update settings: {}", e);
});
if previous_server_url != settings.server_url {
// Only trigger re-sync if both URLs are Some and different, or if one is Some and other is None
if previous_server_url.as_deref() != settings.server_url.as_deref() {
// If the server url has changed, we'll need to do a full re-sync.
self.delete_all_conversations().await.unwrap_or_else(|e| {
log::error!(target: target::SYNC, "Failed to delete all conversations: {}", e);
@@ -267,12 +269,12 @@ impl Daemon {
self.spawn_conversation_list_sync();
// Also restart the update monitor.
self.update_monitor_command_tx
if let Err(e) = self.update_monitor_command_tx
.as_ref()
.unwrap()
.send(UpdateMonitorCommand::Restart)
.await
.unwrap();
.try_send(UpdateMonitorCommand::Restart) {
log::warn!(target: target::UPDATES, "Failed to send restart command to update monitor: {}", e);
}
}
reply.send(()).unwrap();

View File

@@ -34,7 +34,7 @@ pub struct UpdateMonitor {
impl UpdateMonitor {
pub fn new(database: Arc<Mutex<Database>>, event_sender: Sender<Event>) -> Self {
let (command_tx, command_rx) = tokio::sync::mpsc::channel(1);
let (command_tx, command_rx) = tokio::sync::mpsc::channel(100);
Self {
database,
event_sender,