#989·qmd

`qmd update` deactivates every document when a collection root is missing (unmounted drive)

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

Impact

When a collection's root folder is not there at qmd update time (external drive unmounted, network share offline, folder renamed), every document in that collection is deactivated. qmd search and qmd query return nothing for it, and the command still exits 0 with ✓ All collections updated. If qmd cleanup runs before the folder comes back, the rows and their content are hard-deleted, so the loss is permanent and the next update re-indexes and re-embeds from scratch.

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\n' > /tmp/notes/a.md
qmd collection add /tmp/notes --name notes      # Indexed: 1 new
mv /tmp/notes /tmp/notes.unmounted
qmd update
# Indexed: 0 new, 0 updated, 0 unchanged, 1 removed
# ✓ All collections updated.
qmd search zebra                                # No results found.
qmd cleanup                                     # ✓ Removed 1 inactive document records
                                                # ✓ Removed 1 orphaned content hashes

Cause

reindexCollection in src/store.ts globs the root with fast-glob, which returns [] for a folder that does not exist. The deactivation pass at the end of the function then treats every active document as deleted. The SDK store.update() goes through the same function.

Suggested fix

Check that the root exists and is a directory before globbing. If it is not, leave the index unchanged and report the collection as not found. A genuinely empty folder should still deactivate everything as it does today.

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