mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
First pass to fix attachment deleted in history
This commit is contained in:
@@ -325,8 +325,8 @@ class Entry : Node, EntryVersionedInterface<Group> {
|
||||
entryKDBX?.stopToManageFieldReferences()
|
||||
}
|
||||
|
||||
fun getAttachments(binaryPool: BinaryPool): ArrayList<Attachment> {
|
||||
val attachments = ArrayList<Attachment>()
|
||||
fun getAttachments(binaryPool: BinaryPool): Set<Attachment> {
|
||||
val attachments = HashSet<Attachment>()
|
||||
entryKDB?.getAttachments()?.let {
|
||||
attachments.addAll(it)
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
// Remove binaries from the list
|
||||
rootGroup?.doForEachChild(object : NodeHandler<EntryKDBX>() {
|
||||
override fun operate(node: EntryKDBX): Boolean {
|
||||
node.getAttachments(binaryPool).forEach {
|
||||
node.getAttachments(binaryPool, true).forEach {
|
||||
binariesToRemove.remove(it.binaryAttachment)
|
||||
}
|
||||
return binariesToRemove.isNotEmpty()
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.kunzisoft.keepass.utils.ParcelableUtil
|
||||
import com.kunzisoft.keepass.utils.UnsignedLong
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.collections.LinkedHashMap
|
||||
|
||||
class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInterface {
|
||||
@@ -283,13 +284,18 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
|
||||
fields[label] = value
|
||||
}
|
||||
|
||||
fun getAttachments(binaryPool: BinaryPool): ArrayList<Attachment> {
|
||||
val entryAttachmentList = ArrayList<Attachment>()
|
||||
fun getAttachments(binaryPool: BinaryPool, inHistory: Boolean = false): Set<Attachment> {
|
||||
val entryAttachmentList = HashSet<Attachment>()
|
||||
for ((label, poolId) in binaries) {
|
||||
binaryPool[poolId]?.let { binary ->
|
||||
entryAttachmentList.add(Attachment(label, binary))
|
||||
}
|
||||
}
|
||||
if (inHistory) {
|
||||
history.forEach {
|
||||
entryAttachmentList.addAll(it.getAttachments(binaryPool, false))
|
||||
}
|
||||
}
|
||||
return entryAttachmentList
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
attachmentsContainerView.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
fun assignAttachments(attachments: ArrayList<Attachment>,
|
||||
fun assignAttachments(attachments: Set<Attachment>,
|
||||
streamDirection: StreamDirection,
|
||||
onAttachmentClicked: (attachment: Attachment)->Unit) {
|
||||
showAttachments(attachments.isNotEmpty())
|
||||
|
||||
@@ -284,7 +284,7 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
return attachmentsAdapter.itemsList.map { it.attachment }
|
||||
}
|
||||
|
||||
fun assignAttachments(attachments: ArrayList<Attachment>,
|
||||
fun assignAttachments(attachments: Set<Attachment>,
|
||||
streamDirection: StreamDirection,
|
||||
onDeleteItem: (attachment: Attachment)->Unit) {
|
||||
attachmentsContainerView.visibility = if (attachments.isEmpty()) View.GONE else View.VISIBLE
|
||||
|
||||
Reference in New Issue
Block a user