#991·qmd

`qmd update` keeps the old content of a file that became empty

Author: ParkerRexCreated Sep 26, 2026Updated Sep 26, 2026

Impact

When an indexed markdown file is emptied (truncated to zero bytes or to whitespace only), qmd update skips it silently, counting it under no bucket, and its previous body stays active in the index. search, query and get keep returning content that no longer exists on disk. A file that is deleted is deactivated correctly; a file that is emptied is not.

Repro (main @ 04e4dbd)

bash
export QMD_CONFIG_DIR=/tmp/qmd-cfg INDEX_PATH=/tmp/qmd-index.sqlite
mkdir -p /tmp/notes && printf '# A\n\nzebra body\n' > /tmp/notes/a.md
qmd collection add /tmp/notes --name notes      # Indexed: 1 new
: > /tmp/notes/a.md                             # file is now empty
qmd update                                      # Indexed: 0 new, 0 updated, 0 unchanged, 0 removed
qmd search zebra                                # still returns "zebra body"
qmd get qmd://notes/a.md                        # still returns the old body

Cause

In reindexCollection (src/store.ts) the path is added to seenPaths before the empty-content check. The empty check then continues, so the existing row is never updated and the end-of-pass deactivation skips it because the path counts as seen.

Suggested fix

Treat an emptied file the way a deleted file is treated: do not count it as seen, so the deactivation pass at the end marks the row inactive. Writing content back reactivates it through the normal insert path. Empty files at first index are already skipped, so this makes the two cases consistent.

I have a small fix with a test ready and will open a PR.