diff --git a/app/src/main/java/com/kunzisoft/keepass/database/element/database/BinaryPool.kt b/app/src/main/java/com/kunzisoft/keepass/database/element/database/BinaryPool.kt index 1d7e71d96..a94281a88 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/element/database/BinaryPool.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/element/database/BinaryPool.kt @@ -21,12 +21,16 @@ package com.kunzisoft.keepass.database.element.database import java.io.File import java.io.IOException +import kotlin.math.abs abstract class BinaryPool { protected val pool = LinkedHashMap() - private var binaryFileIncrement = 0L // Unique file id (don't use current time because CPU too fast) + // To build unique file id + private var creationId: String = System.currentTimeMillis().toString() + private var poolId: String = abs(javaClass.simpleName.hashCode()).toString() + private var binaryFileIncrement = 0L /** * To get a binary by the pool key (ref attribute in entry) @@ -42,7 +46,7 @@ abstract class BinaryPool { key: T? = null, compression: Boolean = false, protection: Boolean = false): KeyBinary { - val fileInCache = File(cacheDirectory, binaryFileIncrement.toString()) + val fileInCache = File(cacheDirectory, "$poolId$creationId$binaryFileIncrement") binaryFileIncrement++ val newBinaryFile = BinaryFile(fileInCache, compression, protection) val newKey = put(key, newBinaryFile)