Identify the exact stored Vault revision, including entry type, frontmatter, and body rather than only the body content hash.
(entry: &VaultEntry)
| 77 | /// Identify the exact stored Vault revision, including entry type, |
| 78 | /// frontmatter, and body rather than only the body content hash. |
| 79 | fn vault_entry_revision_hash(entry: &VaultEntry) -> String { |
| 80 | let mut hasher = Hasher::new(); |
| 81 | hasher.update(b"atomic-vault-revision-v1"); |
| 82 | append_revision_field(&mut hasher, entry.entry_type.as_str().as_bytes()); |
| 83 | append_revision_field(&mut hasher, entry.frontmatter_json.as_bytes()); |
| 84 | append_revision_field(&mut hasher, &entry.content_bytes); |
| 85 | hasher.finalize().to_base32() |
| 86 | } |
| 87 | |
| 88 | fn append_revision_field(hasher: &mut Hasher, value: &[u8]) { |
| 89 | hasher.update(&(value.len() as u64).to_be_bytes()); |