(noteId: string)
| 327 | // Identical to head → nothing to record |
| 328 | if (head?.content_hash && head.content_hash === hash) return null; |
| 329 | |
| 330 | // Defense-in-depth: never record an accidental wipe as a version. A |
| 331 | // transient empty doc (load race, reconnect, stale beacon) snapshotted |
| 332 | // over real content is what corrupts history into "deleted everything" |
| 333 | // diffs. If the new content is blank but the previous version had text, |
| 334 | // skip — the client-side guard should already prevent this, but old |
| 335 | // clients and the unmount beacon can still slip an empty doc through. |
| 336 | // Fail closed: if we can't read the previous version (R2 blip), don't |
| 337 | // record the empty doc either. |
| 338 | if (head && isEmptyDoc(content)) { |
| 339 | let prevContent: string; |
| 340 | try { |
| 341 | prevContent = await this.reconstructVersion(head.id, noteId, { strict: true }); |
| 342 | } catch { |
no test coverage detected