Skip to content

Commit

Permalink
fix: gracefully handle lock reading
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse committed Jan 20, 2025
1 parent 847a8df commit cd3658b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/core/src/persist/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Persister {
record_type: RecordType,
updated_fields: Option<Vec<String>>,
) -> Result<()> {
if self.sync_trigger.read().unwrap().is_none() {
if self.sync_trigger.try_read().is_ok_and(|t| t.is_none()) {
return Ok(());
}

Expand Down Expand Up @@ -499,8 +499,10 @@ impl Persister {
}

pub(crate) fn trigger_sync(&self) -> Result<()> {
if let Some(trigger) = self.sync_trigger.read().unwrap().deref() {
return Ok(trigger.try_send(())?);
if let Ok(lock) = self.sync_trigger.try_read() {
if let Some(trigger) = lock.clone() {
trigger.try_send(())?;
}
}
Ok(())
}
Expand Down

0 comments on commit cd3658b

Please sign in to comment.