mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix actions duplicate entries
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.element
|
||||
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException
|
||||
import com.kunzisoft.keepass.database.exception.KeyFileEmptyException
|
||||
import com.kunzisoft.keepass.utils.MemUtil
|
||||
@@ -234,8 +235,11 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
||||
|
||||
fun addGroupIndex(group: Group) {
|
||||
val groupId = group.nodeId
|
||||
if (!groupIndexes.containsKey(groupId))
|
||||
if (groupIndexes.containsKey(groupId)) {
|
||||
Log.e(TAG, "Error, a group with the same UUID $groupId already exists")
|
||||
} else {
|
||||
this.groupIndexes[groupId] = group
|
||||
}
|
||||
}
|
||||
|
||||
fun removeGroupIndex(group: Group) {
|
||||
@@ -266,8 +270,11 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
||||
|
||||
fun addEntryIndex(entry: Entry) {
|
||||
val entryId = entry.nodeId
|
||||
if (!entryIndexes.containsKey(entryId))
|
||||
if (entryIndexes.containsKey(entryId)) {
|
||||
Log.e(TAG, "Error, a group with the same UUID $entryId already exists, change the UUID")
|
||||
} else {
|
||||
this.entryIndexes[entryId] = entry
|
||||
}
|
||||
}
|
||||
|
||||
fun removeEntryIndex(entry: Entry) {
|
||||
@@ -310,7 +317,7 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
||||
}
|
||||
|
||||
open fun removeEntryFrom(entryToRemove: Entry, parent: Group?) {
|
||||
// Remove entry for parent
|
||||
// Remove entry from parent
|
||||
parent?.removeChildEntry(entryToRemove)
|
||||
removeEntryIndex(entryToRemove)
|
||||
}
|
||||
@@ -336,6 +343,8 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TAG = "PwDatabase"
|
||||
|
||||
val UUID_ZERO = UUID(0, 0)
|
||||
|
||||
fun hexStringToByteArray(s: String): ByteArray {
|
||||
|
||||
@@ -12,9 +12,9 @@ abstract class PwGroup
|
||||
|
||||
private var titleGroup = ""
|
||||
@Transient
|
||||
private val childGroups = LinkedHashSet<Group>()
|
||||
private val childGroups = ArrayList<Group>()
|
||||
@Transient
|
||||
private val childEntries = LinkedHashSet<Entry>()
|
||||
private val childEntries = ArrayList<Entry>()
|
||||
|
||||
constructor() : super()
|
||||
|
||||
@@ -39,20 +39,22 @@ abstract class PwGroup
|
||||
set(value) { titleGroup = value }
|
||||
|
||||
override fun getChildGroups(): MutableList<Group> {
|
||||
return childGroups.toMutableList()
|
||||
return childGroups
|
||||
}
|
||||
|
||||
override fun getChildEntries(): MutableList<Entry> {
|
||||
return childEntries.toMutableList()
|
||||
return childEntries
|
||||
}
|
||||
|
||||
override fun addChildGroup(group: Group) {
|
||||
// TODO duplicate UUID
|
||||
if (childGroups.contains(group))
|
||||
removeChildGroup(group)
|
||||
this.childGroups.add(group)
|
||||
}
|
||||
|
||||
override fun addChildEntry(entry: Entry) {
|
||||
// TODO duplicate UUID
|
||||
if (childEntries.contains(entry))
|
||||
removeChildEntry(entry)
|
||||
this.childEntries.add(entry)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user