mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix binaries unique Ids #713
This commit is contained in:
@@ -107,6 +107,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
val customData = HashMap<String, String>()
|
||||
|
||||
var binaryPool = BinaryPool()
|
||||
private var binaryIncrement = 0 // Unique id (don't use current time because CPU too fast)
|
||||
|
||||
var localizedAppName = "KeePassDX"
|
||||
|
||||
@@ -561,7 +562,8 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
compression: Boolean,
|
||||
binaryPoolId: Int? = null): BinaryAttachment {
|
||||
// New file with current time
|
||||
val fileInCache = File(cacheDirectory, System.currentTimeMillis().toString())
|
||||
val fileInCache = File(cacheDirectory, binaryIncrement.toString())
|
||||
binaryIncrement++
|
||||
val binaryAttachment = BinaryAttachment(fileInCache, protection, compression)
|
||||
// add attachment to pool
|
||||
binaryPool.put(binaryPoolId, binaryAttachment)
|
||||
|
||||
@@ -954,7 +954,13 @@ class DatabaseInputKDBX(cacheDirectory: File,
|
||||
xpp.next() // Consume end tag
|
||||
val id = Integer.parseInt(ref)
|
||||
// A ref is not necessarily an index in Database V3.1
|
||||
mDatabase.binaryPool[id]
|
||||
var binaryRetrieve = mDatabase.binaryPool[id]
|
||||
// Create empty binary if not retrieved in pool
|
||||
if (binaryRetrieve == null) {
|
||||
binaryRetrieve = mDatabase.buildNewBinary(cacheDirectory,
|
||||
protection = false, compression = false, binaryPoolId = id)
|
||||
}
|
||||
return binaryRetrieve
|
||||
}
|
||||
key != null -> {
|
||||
createBinary(key.toIntOrNull(), xpp)
|
||||
|
||||
Reference in New Issue
Block a user