don't send empty patches

This commit is contained in:
Aiden McClelland
2024-06-24 10:43:10 -06:00
parent 72c62cd525
commit faab5ff083
3 changed files with 10 additions and 2 deletions

View File

@@ -211,6 +211,10 @@ impl DiffPatch {
} }
keys keys
} }
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
} }
impl Default for DiffPatch { impl Default for DiffPatch {
fn default() -> Self { fn default() -> Self {

View File

@@ -7,7 +7,11 @@ use crate::Revision;
struct ScopedSender(JsonPointer, mpsc::UnboundedSender<Revision>); struct ScopedSender(JsonPointer, mpsc::UnboundedSender<Revision>);
impl ScopedSender { impl ScopedSender {
fn send(&self, revision: &Revision) -> Result<(), mpsc::error::SendError<Revision>> { fn send(&self, revision: &Revision) -> Result<(), mpsc::error::SendError<Revision>> {
self.1.send(revision.for_path(&self.0)) let scoped = revision.for_path(&self.0);
if scoped.patch.is_empty() {
return Ok(());
}
self.1.send(scoped)
} }
} }