Skip to content

Fix split library paths in CWA workflows - #1474

Open
iuyo5678 wants to merge 2 commits into
crocodilestick:mainfrom
iuyo5678:fix/split-library-paths
Open

iuyo5678 wants to merge 2 commits into
crocodilestick:mainfrom
iuyo5678:fix/split-library-paths

Conversation

@iuyo5678

@iuyo5678 iuyo5678 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • generate post-ingest KOReader checksums against the configured metadata.db, not the split book-files root
  • back up automatically resolved duplicate books from config.get_book_path()
  • run calibredb check_library and restore_database with the book-files root plus CALIBRE_OVERRIDE_DATABASE_PATH in split-library mode
  • preserve the existing behavior for non-split libraries

Problem

When Separate Book Files from Library is enabled, CWA keeps metadata.db in config_calibre_dir and stores book files in config_calibre_split_dir. A few workflows still treated config_calibre_dir and the book-files root as the same directory. This caused checksum generation to open a non-existent database under the books directory, duplicate resolution to look for backup sources under the database directory, and Calibre database check/restore commands to receive the wrong library context.

Tests

pytest -q -m unit \
  tests/unit/test_calibre_cli.py \
  tests/unit/test_ingest_batch_dirty.py \
  tests/unit/test_duplicate_delete_index_maintenance.py

7 passed, 4 deselected

Additional checks:

  • git diff --check
  • Python compileall for all changed Python files
  • Ruff E4,E7,E9,F checks for the new helper and its tests

@iuyo5678

Copy link
Copy Markdown
Author

I pushed a follow-up commit that restores the stubbed modules after the new
unit test, preventing pytest worker state from leaking into subsequent tests.

The original failing tests now pass locally in the same xdist worker.
Could a maintainer please approve and run the updated workflow?

@pcc0x

pcc0x commented Oct 15, 2026

Copy link
Copy Markdown

This also fixes #1513. I see the same bug on v4.0.6, and the line is unchanged in v4.0.8.

The conflict with main is only in generate_book_checksums: main added a KOReader sync check just above the changed line (commit 596300f). Keeping that check and then using self.metadata_db resolves it. The new test then needs is_koreader_sync_enabled patched to return True, otherwise the function returns before the checksum code runs. With both changes the test passes, and on current main it fails with "no such table: books".

Would you like to rebase? If you'd rather not, I can open a pull request with just the checksum part on top of current main.

@pcc0x

pcc0x commented Nov 10, 2026

Copy link
Copy Markdown

I opened #1667 with just the checksum fix and its test on top of current main, so that part can merge on its own. It follows your change here and credits this PR.

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.

3 participants