Skip to content

feature: cache EPUB on startup - #30

Merged
dastarruer merged 1 commit into
masterfrom
feature/cache-opened-epub
May 10, 2026
Merged

feature: cache EPUB on startup#30
dastarruer merged 1 commit into
masterfrom
feature/cache-opened-epub

Conversation

@dastarruer

@dastarruer dastarruer commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Create EpubWrapper struct to store metadata and EPUB.
  • Remove obsolete calls to Epub::open()
  • Update documentation to reflect changes

Summary by CodeRabbit

Release Notes

  • Refactor
    • Optimized EPUB file handling: Files are now loaded once at app startup and cached in memory, rather than repeatedly accessed from disk.
    • Improved metadata retrieval: Now cached and retrieved synchronously for faster response times.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR refactors the application to store opened EPUB files and metadata in application state instead of filesystem paths. Bootstrap now opens the EPUB at startup and caches metadata. Commands and the URI protocol handler read from the stored wrapper, eliminating file-opening calls and enabling synchronous metadata retrieval.

Changes

EPUB-backed Application Data Refactoring

Layer / File(s) Summary
Data Structures & Contracts
src-tauri/src/lib.rs, src-tauri/src/commands/metadata.rs
New EpubWrapper struct holds opened rbook::Epub and Metadata; AppData field changes from source: PathBuf to epub: EpubWrapper; Metadata gains Clone derive and changes From<Epub> to From<&Epub>.
Command Refactoring
src-tauri/src/commands/content.rs, src-tauri/src/commands/metadata.rs
Commands refactored to accept &EpubWrapper and read from cached state: read_epub_metadata becomes synchronous (no I/O), get_resource and get_epub_content_inner operate on wrapper.epub instead of opening from path.
Bootstrap & Protocol Handling
src-tauri/src/lib.rs
bootstrap_app() opens EPUB file at startup, extracts metadata, and constructs EpubWrapper; epub:// URI handler reads from protocol_data.epub instead of filesystem source.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • dastarruer/epub-editor#7: This PR builds directly on the earlier EPUB reading functionality—it replaces PathBuf-backed app state with an EpubWrapper that stores the opened rbook::Epub and cached Metadata.
  • dastarruer/epub-editor#13: Related via shared command refactoring—both PRs modify get_epub_content and get_resource to work with EpubWrapper state instead of opening files.
  • dastarruer/epub-editor#14: Related through module organization—this PR refactors the content.rs module (and its imports) while the PR here changes function signatures and implementation to use EpubWrapper.

Poem

🐰 Hops with glee at files now stored,
No more paths to open and explore!
Metadata cached, commands flow fast,
Bootstrap opens EPUB once—a task well-cast. ✨📖

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: caching EPUB data on startup instead of reading from path each time, which aligns with the refactoring across all three files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/cache-opened-epub

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dastarruer
dastarruer merged commit 1a312d6 into master May 10, 2026
2 checks passed
@dastarruer
dastarruer deleted the feature/cache-opened-epub branch May 10, 2026 15:48
@dastarruer dastarruer mentioned this pull request May 10, 2026
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