no double persist snapshot

This commit is contained in:
Bel LaPointe
2025-12-01 17:05:07 -07:00
parent 700b2a22cc
commit 4ad0b7d2ff

View File

@@ -167,7 +167,9 @@ impl File {
pub fn stage_persisted(&self) -> Result<(), String> {
let persisted_as_snapshot = self.events()?.snapshot()?;
self.append(Delta::snapshot(persisted_as_snapshot.clone()))?;
if persisted_as_snapshot != self.events()?.last_snapshot() {
self.append(Delta::snapshot(persisted_as_snapshot.clone()))?;
}
let plaintext = serde_yaml::to_string(&persisted_as_snapshot).unwrap();
let mut f = std::fs::File::create(&self.file).expect("failed to open file for writing");
writeln!(f, "{}", plaintext).expect("failed to write");