Fix crash when adding attachment to existing entry#280
Conversation
WalkthroughThe changes involve modifications to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- app/src/main/kotlin/com/ivanovsky/passnotes/data/repository/keepass/kotpass/KotpassNoteDao.kt (3 hunks)
🧰 Additional context used
🔇 Additional comments (4)
app/src/main/kotlin/com/ivanovsky/passnotes/data/repository/keepass/kotpass/KotpassNoteDao.kt (4)
197-199: Verify the use ofoldBinariesMapwhen callingprepareAttachmentsDiffIn lines 197-199, when calling
prepareAttachmentsDiff, you are usingoldBinariesMap = db.getRawDatabase().binaries. Please verify thatoldBinariesMapincludes all necessary binaries, especially ifnewNoteornewHistorycontains new binaries not present in the old database. This can prevent potential issues where attachments are not properly updated.
282-300:toAttachmentsfunction implementation is correctThe
toAttachmentsextension function from lines 282-300 correctly converts a list ofBinaryReferenceobjects into a list ofAttachmentobjects. It efficiently avoids duplicates by checking for existing keys based on the binary hash, ensuring that each attachment is unique.
304-306: UpdatedprepareAttachmentsDiffmethod signature enhances clarityThe changes to the
prepareAttachmentsDiffmethod parameters in lines 304-306 improve the method's clarity and better reflect its usage. PassingoldBinariesMap,newNote, andnewHistorymakes the function more flexible and aligns with the updated attachment handling logic.
308-318: Ensure all binaries are accounted for inoldAttachmentsIn lines 308-318, when constructing
oldAttachments, you collect binaries fromoldEntryand its history usingoldBinariesMap. Please verify that all relevant binaries are included, especially if there have been changes to the binaries in the history entries that might not be present inoldBinariesMap.
Summary by CodeRabbit
New Features
Bug Fixes