Skip to content

Commit

Permalink
Merge pull request #282 from aivanovski/feature/279-issue-with-keepas…
Browse files Browse the repository at this point in the history
…sdx-if-i-open-database-via-keepassvault

Fix entry update logic
  • Loading branch information
aivanovski authored Oct 19, 2024
2 parents 0a8f5f4 + fe9fd38 commit 4709f5e
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class KotpassNoteDao(
.drop(excessiveHistoryItems)
.toMutableList()
.apply {
add(oldEntry)
add(oldEntry.copy(history = emptyList()))
}
} else {
emptyList()
Expand Down Expand Up @@ -313,19 +313,17 @@ class KotpassNoteDao(
addAll(historyEntry.binaries)
}
}
.distinctBy { reference -> reference.hash }
.toAttachments(
allBinaries = oldBinariesMap
)

val newAttachments = mutableListOf<Attachment>()
.apply {
addAll(
newHistory
.flatMap { entry -> entry.binaries }
.toAttachments(allBinaries = oldBinariesMap)
)
addAll(newNote.attachments)
}
val newHistoryAttachments = newHistory
.flatMap { entry -> entry.binaries }
.toAttachments(allBinaries = oldBinariesMap)

val newAttachments = (newHistoryAttachments + newNote.attachments)
.distinctBy { attachment -> attachment.hash }

val attachmentsDiff = differ.getAttachmentsDiff(oldAttachments, newAttachments)
return if (attachmentsDiff.isNotEmpty()) {
Expand Down

0 comments on commit 4709f5e

Please sign in to comment.