Skip to content

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

Closed

Description

@ParkerRex

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)

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.

Activity

  1. added a commit that references this issue on Sep 30, 2026
    f8416e7
  2. added 4 commits that reference this issue on Oct 2, 2026
    afbc2f7
    0d9b7d1
    20fa36e
    09a18b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions