Skip to content

Latest commit

 

History

History
408 lines (354 loc) · 21.5 KB

File metadata and controls

408 lines (354 loc) · 21.5 KB

Booklore KOReader Plugin - Feature List

Last Updated: February 11, 2026
Plugin Version: 1.0.0-beta
Status: Ready for Testing

This document tracks all features from the old plugin and their implementation status in the new plugin.

Legend

  • Fully Implemented - Feature is complete and working
  • 🚧 Partially Implemented - Feature exists but not fully functional
  • Not Implemented - Feature not yet added to new plugin

Core Features

Authentication & Connection

Feature Status Location (New) Notes
Server URL configuration booklore_settings.lua:17-56
Username configuration booklore_settings.lua:58-96
Password configuration booklore_settings.lua:98-137
Test connection main.lua:503-551, booklore_api_client.lua:238-262 Enhanced with better error handling
MD5 password hashing booklore_api_client.lua:145

Session Tracking

Feature Status Location (New) Notes
Automatic session start on document open main.lua:843-891, main.lua:1026-1029 onReaderReady handler
Automatic session end on document close main.lua:893-996, main.lua:1034-1040 onCloseDocument handler
Session start/end on suspend/resume main.lua:1045-1049, main.lua:1054-1073 onSuspend/onResume handlers
Track reading progress (start/end) main.lua:616-651 Supports PDF and EPUB formats
Track reading duration main.lua:893-996 Calculates duration in seconds
Book hash calculation (MD5) main.lua:668-723 Sample-based FileFingerprint algorithm
Book ID lookup by hash main.lua:725-777, booklore_api_client.lua:271-284 With database caching
Support for EPUB format main.lua:631-641, main.lua:653-666 Full support
Support for PDF format main.lua:623-629, main.lua:653-666 Full support
Round progress to decimal places main.lua:605-608 Helper function implemented
Get current progress and location main.lua:616-651 New helper function
Detect book type from file extension main.lua:653-666 Supports EPUB, PDF, DJVU, CBZ, CBR

Session Validation

Feature Status Location (New) Notes
Minimum session duration (seconds) main.lua:574-594, booklore_settings.lua:139-181 Fully integrated
Minimum pages read main.lua:574-594, booklore_settings.lua:183-225 Fully integrated
Session detection mode (duration/pages) main.lua:574-594, main.lua:237-272 Fully integrated
Skip sessions with no progress main.lua:588-590 Fully integrated

Offline Support

Feature Status Location (New) Notes
Queue sessions when offline booklore_database.lua:508-557, main.lua:966-977 Database support + session end integration
Sync pending sessions main.lua:1060-1211 Fully implemented with retry logic
Auto-sync on resume main.lua:1063-1066 Silent background sync
Auto-sync on reader ready - Not implemented (by design)
Auto-sync after session end main.lua:979-983 If not in manual-only mode
Clear pending sessions main.lua:314-322, booklore_database.lua:617-621
View pending session count main.lua:325-334, booklore_database.lua:623-638
Session retry tracking booklore_database.lua:640-658 Database support + increment function
Format duration (Xh Ym Zs) main.lua:543-557 New feature with type safety
Book ID resolution during sync main.lua:1110-1146 Resolves NULL book_id from server

Cache Management

Feature Status Location (New) Notes
Book hash to ID mapping cache booklore_database.lua:278-342 SQLite-based cache
File path to hash mapping cache booklore_database.lua:278-342 SQLite-based cache
Cache statistics view main.lua:337-362, booklore_database.lua:465-489
Clear cache main.lua:364-383, booklore_database.lua:491-497
Migration from LuaSettings to SQLite main.lua:72-110, booklore_database.lua:704-768 Complete with data migration
Update book ID by hash booklore_database.lua:444-463 For resolving offline sessions

Sync Options

Feature Status Location (New) Notes
Manual sync only mode main.lua:206-227, main.lua:392-399 Fully integrated
Force push on suspend 🚧 main.lua:402-422 Setting exists, behavior deferred
Connect network on suspend 🚧 main.lua:425-438 Setting exists, behavior deferred
Silent messages mode booklore_settings.lua:305-320

Network Management

Feature Status Location (New) Notes
Enable WiFi on suspend - Deferred - Old: old/main.lua:404-441
Wait for network (15s timeout) - Deferred - Old: old/main.lua:423-440
Quick network connectivity check booklore_api_client.lua:317-331 Via health check endpoint

Historical Data

Feature Status Location (New) Notes
Sync from statistics.sqlite3 🚧 main.lua:589-624 Placeholder only - deferred for post-launch
Group page stats into sessions - Deferred - Old: old/main.lua:1194-1235
Session timeout detection (5 min) - Deferred - Old: old/main.lua:1196
Historical sync acknowledgment main.lua:597-616 Warning dialog
Match historical data 🚧 main.lua:626-631 Placeholder only
View match statistics main.lua:633-653
Match history database booklore_database.lua:660-702 Schema ready

Dispatcher Integration

Feature Status Location (New) Notes
Toggle sync action main.lua:132-138, main.lua:166-169
Sync pending sessions action main.lua:141-146, main.lua:171-184
Toggle manual sync only action main.lua:149-154, main.lua:191-194
Test connection action main.lua:156-163, main.lua:186-189

Settings & Configuration

Feature Status Location (New) Notes
Enable/disable sync booklore_settings.lua:273-287
Log to file 🚧 booklore_settings.lua:289-304 UI exists, file logging deferred
Progress decimal places (0-5) main.lua:291-296, booklore_settings.lua:227-269
Server URL input dialog booklore_settings.lua:17-56
Username input dialog booklore_settings.lua:58-96
Password input dialog booklore_settings.lua:98-137
Min duration input dialog booklore_settings.lua:139-181
Min pages input dialog booklore_settings.lua:183-225 New feature
Version display button booklore_settings.lua:271-285, booklore_settings.lua:377-383 New feature

Menu Structure

Feature Status Location (New) Notes
Main "Booklore Sync" menu main.lua:229-479 Complete menu structure
Login submenu booklore_settings.lua:338-375
Session Management submenu main.lua:233-385 Enhanced with detection mode
Sync Options submenu main.lua:388-441
Historical Data submenu main.lua:444-475 New submenu structure
About & Updates submenu main.lua:545-588 New feature (Feb 15, 2026)
Version button in settings booklore_settings.lua:377-383 New feature with version info

Auto-Update System (NEW - Feb 15, 2026)

Feature Status Location (New) Notes
GitHub API integration booklore_updater.lua:236-287 Fetches latest release
Semantic version parsing booklore_updater.lua:96-125 Handles vX.Y.Z format
Version comparison logic booklore_updater.lua:127-161 Dev versions always update
Auto-check on startup main.lua:152-159, main.lua:2894-2941 Once per day, 5-second delay
Manual update check main.lua:2943-3015 Via menu action
Download with progress booklore_updater.lua:394-449 Shows percentage
Automatic backup booklore_updater.lua:499-521 Before installation
Atomic installation booklore_updater.lua:523-583 Safe replacement
Rollback support booklore_updater.lua:585-619, main.lua:3096-3118 Restore from backup
Cache release info (1hr) booklore_updater.lua:289-320, booklore_database.lua:1608-1689 Reduce API calls
Backup retention (3 latest) booklore_updater.lua:639-664 Auto-cleanup old backups
Download size display booklore_updater.lua:380-392 Human-readable format
Changelog preview main.lua:2976-2979 Shows in update dialog
Restart prompt main.lua:3080-3090 UIManager:askForRestart()
Network check before update main.lua:2949-2956 NetworkMgr integration
Update available badge main.lua:548, main.lua:560 Menu shows ⚠
Toggle auto-check setting main.lua:3120-3132 Enable/disable
Clear update cache main.lua:3134-3143 Force fresh check
Version info display main.lua:2862-2892 Current version details
updater_cache database table booklore_database.lua:213-220 Migration 8

API Communication

Feature Status Location (New) Notes
GET /api/koreader/users/auth booklore_api_client.lua:238-262 Authentication endpoint
GET /api/koreader/books/by-hash/:hash booklore_api_client.lua:271-284 Book lookup by hash
POST /api/v1/reading-sessions booklore_api_client.lua:293-309 Session submission
GET /api/v1/healthcheck booklore_api_client.lua:317-331 Health check
HTTP timeout (10s) booklore_api_client.lua:22 Configurable timeout
HTTPS support booklore_api_client.lua:173-176 Full HTTPS support
JSON request encoding booklore_api_client.lua:156 Using cjson
JSON response parsing booklore_api_client.lua:52-64 With error handling
Error message extraction booklore_api_client.lua:79-117 Enhanced error messages

Database (SQLite)

Feature Status Location (New) Notes
Schema versioning booklore_database.lua:14, booklore_database.lua:146-182 Current version: 1
Schema migrations booklore_database.lua:21-97, booklore_database.lua:184-275 Migration framework ready
book_cache table booklore_database.lua:25-46 Complete with indexes
pending_sessions table booklore_database.lua:49-70 With retry tracking
WAL mode for concurrency booklore_database.lua:125 Better performance
Foreign key support booklore_database.lua:122 Referential integrity
Database cleanup on exit main.lua:124-128 Proper cleanup
Type-safe reads booklore_database.lua (all read functions) tonumber/tostring conversions
INSERT OR REPLACE for upserts booklore_database.lua:284-341 Atomic operations
Delete pending session booklore_database.lua:602-615 After successful sync
Get book by file path booklore_database.lua:344-370 With type conversions
Get book by hash booklore_database.lua:372-398 With type conversions
Save book cache booklore_database.lua:284-341 Upsert operation
Add pending session booklore_database.lua:508-557 With validation
Get pending sessions booklore_database.lua:560-600 Batched with limit
Get cache statistics booklore_database.lua:465-489 Count queries
Clear book cache booklore_database.lua:491-497 Truncate table
Clear pending sessions booklore_database.lua:617-621 Truncate table
Increment retry count booklore_database.lua:640-658 For failed syncs

Logging

Feature Status Location (New) Notes
File logging toggle 🚧 booklore_settings.lua:289-304 UI exists, deferred
Custom log file path - Deferred for post-launch
Log rotation - Deferred for post-launch
Debug/info/warn/err levels Throughout all files Uses KOReader logger

Bug Fixes Applied (Feb 11, 2026)

Critical Fixes

Issue Status Location Description
SQLite bind() API errors All database queries Fixed bind1/bind2/bind3 → bind(val1, val2, ...)
cdata type conversion errors All database reads Added tonumber/tostring conversions
Module name conflicts All modules Renamed to booklore_* prefix
Missing SQLite methods Database operations Removed changes()/last_insert_rowid() calls
formatDuration cdata error main.lua:543-557 Added type conversion at line 546

Summary Statistics

Feature Completion

  • Total Features Tracked: 119 core features (includes 20 new auto-update features)
  • Fully Implemented: 105 (88.2%)
  • Partially Implemented: 6 (5.0%)
  • Not Implemented: 8 (6.7%)

Status Breakdown by Category

Category Complete Partial Missing Total % Done
Authentication & Connection 5 0 0 5 100%
Session Tracking 12 0 0 12 100%
Session Validation 4 0 0 4 100%
Offline Support 10 0 0 10 100%
Cache Management 6 0 0 6 100%
Sync Options 2 2 0 4 50%
Network Management 1 0 2 3 33%
Historical Data 3 2 2 7 43%
Dispatcher Integration 4 0 0 4 100%
Settings & Configuration 8 1 0 9 89%
Menu Structure 7 0 0 7 100%
Auto-Update System 20 0 0 20 100%
API Communication 9 0 0 9 100%
Database (SQLite) 21 0 0 21 100%
Logging 1 1 2 4 25%

Deferred Features (Post-Launch)

The following features are intentionally deferred and not critical for core functionality:

  1. Historical data sync - Can be ported from old plugin later

    • Location: old/main.lua:1059-1356
    • Complexity: High (requires statistics.sqlite3 parsing)
    • Priority: Low
  2. Network management on suspend - WiFi enable/wait logic

    • Location: old/main.lua:404-441
    • Complexity: Medium (device-specific APIs)
    • Priority: Medium
  3. Custom file logging - Write to dedicated log file

    • Location: old/main.lua:46-89
    • Complexity: Low
    • Priority: Low
  4. Force push/connect on suspend behaviors - UI exists but handlers not implemented

    • Complexity: Medium
    • Priority: Low

New Features Added (Not in Old Plugin)

  1. Session detection mode - Choose between duration-based or pages-based validation
  2. Minimum pages read - Additional validation option beyond just duration
  3. Match history tracking - Database table for manual matching of historical data
  4. Version button - Dedicated button in settings to display version info
  5. Enhanced error handling - Better error messages and extraction in API client
  6. SQLite database - More robust than LuaSettings with proper schema versioning
  7. Database migrations - Schema versioning system for future updates
  8. Formatted duration display - Human-readable duration format (e.g., "1h 5m 9s")
  9. Auto-detect book type - Supports EPUB, PDF, DJVU, CBZ, CBR
  10. Auto-sync on resume - Background sync when device wakes up from suspend
  11. Auto-sync after session - Optionally sync immediately after session ends
  12. Book ID resolution during sync - Resolves NULL book_id for offline sessions
  13. Type-safe database operations - All cdata converted to proper Lua types
  14. Atomic upsert operations - INSERT OR REPLACE for better data consistency
  15. Retry tracking per session - Track failed sync attempts per session
  16. Update book ID by hash - Update cached book_id when resolved from server
  17. Auto-updater system - Self-updating plugin from GitHub releases (Feb 15, 2026)
  18. Semantic versioning - Proper version comparison and parsing
  19. Automatic backups - Creates backup before each update
  20. Rollback support - Restore previous version if update fails
  21. Update notifications - Badge indicators and startup notifications
  22. Download progress - Real-time progress during update downloads

Improvements Over Old Plugin

  • Better offline support - Sessions queue with NULL book_id, resolved during sync
  • Type safety - All SQLite cdata properly converted to Lua types
  • Better error handling - Enhanced API error extraction and user messages
  • Atomic operations - INSERT OR REPLACE instead of UPDATE then INSERT
  • Schema versioning - Proper migration framework for future updates
  • Code organization - Separated modules (booklore_settings, booklore_database, booklore_api_client, booklore_updater)
  • Self-updating - No manual file management needed, updates from GitHub automatically
  • Safe updates - Automatic backups and rollback support
  • Version awareness - Clear version tracking and comparison
  • More validation options - Duration AND/OR pages-based validation
  • Better caching - SQLite with indexes instead of LuaSettings
  • Retry logic - Track and increment retry count per failed session
  • No module conflicts - All modules prefixed with "booklore_"

Testing Status

Current State

  • ✅ All Lua syntax valid (verified with luac)
  • ✅ All SQLite binding errors fixed
  • ✅ All cdata type conversions in place
  • ✅ All modules renamed to avoid conflicts
  • Ready for end-to-end testing
  • ⏳ Requires KOReader restart to load fixes

Next Steps

  1. Copy plugin to KOReader - See QUICK_START.md
  2. Restart KOReader completely - Critical for loading fixes
  3. Run 5-minute quick test - See QUICK_START.md
  4. Run comprehensive tests - See TESTING_GUIDE.md
  5. Report results - Document any issues found

Documentation

  • QUICK_START.md - 5-minute test checklist
  • TESTING_GUIDE.md - Comprehensive test plan (7 phases)
  • DEBUG_REFERENCE.md - Debug commands and SQL queries
  • STATUS.md - Current project status
  • BOOK_HASH.md - Hash algorithm documentation
  • SESSION_TRACKING.md - Session lifecycle
  • SYNC_IMPLEMENTATION.md - Sync workflow
  • TYPE_SAFETY_FIX.md - SQLite type conversions
  • VERSIONING.md - Version strategy

Implementation Checklist

✅ Completed (85.9%)

  • Core session tracking (onReaderReady, onCloseDocument, onSuspend, onResume)
  • Book hash calculation (sample-based MD5)
  • Session data collection (progress, location, duration)
  • Session validation (duration/pages with configurable thresholds)
  • Offline support (queue with NULL book_id)
  • Sync pending sessions with retry logic
  • Auto-sync on resume (silent background)
  • Auto-sync after session end (optional)
  • Book ID resolution during sync
  • Database caching (SQLite with migrations)
  • Settings UI (all configuration options)
  • API client (all endpoints)
  • Menu structure (complete hierarchy)
  • Dispatcher integration (all actions)
  • Type-safe database operations
  • Error handling and user feedback
  • Progress rounding helper
  • Duration formatting helper

🚧 Partially Implemented (6.1%)

  • [~] Force push on suspend (UI exists, behavior deferred)
  • [~] Connect network on suspend (UI exists, behavior deferred)
  • [~] Historical data sync (UI exists, implementation deferred)
  • [~] Match historical data (placeholder only)
  • [~] Log to file (UI exists, implementation deferred)

❌ Deferred for Post-Launch (8.1%)

  • WiFi enable/wait on suspend
  • Network timeout management
  • Historical session grouping
  • Statistics.sqlite3 parsing
  • Custom log file writing
  • Log rotation

Ready for Production?

Core Functionality: ✅ YES

The plugin is ready for production use for its core purpose:

  • ✅ Track reading sessions automatically
  • ✅ Sync sessions to Booklore server
  • ✅ Work offline with queue and retry
  • ✅ Handle book hash calculation and caching
  • ✅ Resolve book IDs from server
  • ✅ Validate sessions before saving
  • ✅ User-friendly settings and menus

Advanced Features: ⏳ Post-Launch

Some advanced features are intentionally deferred:

  • Historical data import from statistics.sqlite3
  • Automatic WiFi management
  • Custom log file writing

These can be added in future updates based on user feedback and priority.


Support & Troubleshooting

For testing help:

  1. Quick Start: See QUICK_START.md for 5-minute test
  2. Debug Help: See DEBUG_REFERENCE.md for commands and queries
  3. Full Tests: See TESTING_GUIDE.md for comprehensive plan
  4. Current Status: See STATUS.md for project overview

Last Updated: February 11, 2026
Next Milestone: End-to-end testing and validation