Skip to content

fix(sync): include .pdf in default sync extension allowlist - #394

Open
Wu-Yumin wants to merge 1 commit into
StarTrail-org:mainfrom
Wu-Yumin:fix/sync-pdf-change-detection
Open

fix(sync): include .pdf in default sync extension allowlist#394
Wu-Yumin wants to merge 1 commit into
StarTrail-org:mainfrom
Wu-Yumin:fix/sync-pdf-change-detection

Conversation

@Wu-Yumin

Copy link
Copy Markdown
Contributor

What does this PR do?

leann build indexes PDFs by default (should_process_pdfs in cli.py), but
DEFAULT_INDEX_EXTENSIONS in sync.py — the allowlist used by change detection
for incremental builds and leann watch — includes .docx/.pptx yet not
.pdf. The allowlist's own comment says to keep it in sync with build's
default extension set.

Consequences:

  • A PDF-only directory hashes to an empty set, so detect_changes() reports
    no new files and the first build exits early with Index up to date.,
    leaving behind an empty index directory (shown as ❌ by leann list).
  • PDF additions/modifications/removals are invisible to incremental builds
    and leann watch; only --force rebuilds pick them up.

Fix: add the missing .pdf to DEFAULT_INDEX_EXTENSIONS, plus regression
tests covering PDF hashing and first-build change detection.

Note: #299 fixed the same symptom for multi-document files skipped by
len(file) > 1, and #377 rewrote hashing to raw bytes — but the rewrite
moved file selection to this extension allowlist, which is where PDFs were
dropped. This PR closes that gap. Affected: main and the 0.3.8 tag.

Related Issues

Relates to #290, #14

Checklist

  • Tests pass (uv run pytest) — test_sync.py 10/10; the 3 failures in
    test_incremental_build.py are pre-existing on origin/main (identical
    failure set with and without this change)
  • Code formatted (ruff format and ruff check)
  • Pre-commit hooks pass (pre-commit run --all-files)

PDFs are indexed by 'leann build' by default (should_process_pdfs in
cli.py), but DEFAULT_INDEX_EXTENSIONS in sync.py — used by change
detection for incremental build and 'leann watch' — does not include
'.pdf'. As a result, PDF-only directories hash to an empty set:
detect_changes() reports no new files and the first build exits early
with 'Index up to date.', leaving an empty index directory behind.
PDF additions/modifications/removals are likewise invisible to
incremental builds and watch.

The allowlist's own comment says to keep it in sync with build's
default extension set, so add the missing '.pdf'. Add regression
tests covering hashing and first-build change detection for PDFs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant