From 18c6b2def3db45d43ebbfbfe21f1264e5e2879df Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 7 Oct 2021 15:25:02 -0600 Subject: [PATCH] more logging --- patch-db/src/store.rs | 5 +++-- patch-db/src/transaction.rs | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/patch-db/src/store.rs b/patch-db/src/store.rs index 168ac80..dded388 100644 --- a/patch-db/src/store.rs +++ b/patch-db/src/store.rs @@ -177,6 +177,9 @@ impl Store { return Ok(None); } + #[cfg(feature = "log")] + log::trace!("Attempting to apply patch: {:?}", patch); + self.check_cache_corrupted()?; let patch_bin = serde_cbor::to_vec(&*patch)?; json_patch::patch(self.get_data_mut()?, &*patch)?; @@ -274,8 +277,6 @@ impl PatchDb { } else { self.store.write().await }; - #[cfg(feature = "log")] - log::trace!("Attempting to apply patch: {:?}", patch); let rev = store.apply(patch, expire_id).await?; if let Some(rev) = rev.as_ref() { self.subscriber.send(rev.clone()).unwrap_or_default(); // ignore errors diff --git a/patch-db/src/transaction.rs b/patch-db/src/transaction.rs index 8b18316..c8dbdc2 100644 --- a/patch-db/src/transaction.rs +++ b/patch-db/src/transaction.rs @@ -146,7 +146,13 @@ impl DbHandle for Transaction { self.rebase()?; self.parent.get_value(ptr, Some(store)).await? }; - json_patch::patch(&mut data, &*self.updates.for_path(ptr))?; + let path_updates = self.updates.for_path(ptr); + if !(path_updates.0).0.is_empty() { + #[cfg(feature = "log")] + log::trace!("applying patch {:?} at path {}", path_updates, ptr); + + json_patch::patch(&mut data, &*path_updates)?; + } Ok(data) } async fn put_value + Send + Sync, V: SegList + Send + Sync>(