fix: use correct file extension when generating name off book ID#26
Conversation
📝 WalkthroughWalkthroughThe ChangesBook download path extension fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
grimmory.koplugin/grimmory/synchronize.lua (1)
326-332: ⚡ Quick winConsider adding nil safety check for
book.primary_file.The function accesses
book.primary_file.filenameat lines 333 and 349 without verifying thatbook.primary_fileexists. While the current code path is safe (only books passingisTargetBookreach here), adding a defensive check would prevent potential runtime errors if this function is called directly elsewhere.🛡️ Suggested defensive validation
function GrimmorySynchronize:getBookDownloadPath(book) local download_directory = self.settings:getSyncDownloadDirectory() if not download_directory or download_directory == "" then return nil end + + if not book.primary_file or not book.primary_file.filename then + logger:err("Book missing primary file information:", book.id) + return nil + end local download_path = download_directory .. "/" .. util.getSafeFilename(book.primary_file.filename)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@grimmory.koplugin/grimmory/synchronize.lua` around lines 326 - 332, In GrimmorySynchronize:getBookDownloadPath, add a defensive nil check for book.primary_file before accessing book.primary_file.filename (and any other primary_file fields); if book.primary_file is nil, return nil (or handle accordingly) so calls to getBookDownloadPath outside the isTargetBook path won't error; update the checks around lines referencing book.primary_file.filename to first verify book.primary_file exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@grimmory.koplugin/grimmory/synchronize.lua`:
- Around line 326-332: In GrimmorySynchronize:getBookDownloadPath, add a
defensive nil check for book.primary_file before accessing
book.primary_file.filename (and any other primary_file fields); if
book.primary_file is nil, return nil (or handle accordingly) so calls to
getBookDownloadPath outside the isTargetBook path won't error; update the checks
around lines referencing book.primary_file.filename to first verify
book.primary_file exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ea16e061-8d85-46c7-b8ec-f6ee1c3d7484
📒 Files selected for processing (1)
grimmory.koplugin/grimmory/synchronize.lua
📜 Review details
🔇 Additional comments (3)
grimmory.koplugin/grimmory/synchronize.lua (3)
325-325: LGTM!
349-353: LGTM!
355-355: LGTM!
there was a mismatch in the typing for
getDownloadPathso the bookfilenameproperty was getting accessed but that never existed. instead, switch toprimary.fileNameso that we get a correct file extension for generated book namesSummary by CodeRabbit
Bug Fixes
Documentation