Fix compression after download and upload attachment

This commit is contained in:
J-Jamet committed 2020-08-25 20:07:41 +02:00
1 parent 4ea3e08a45
commit f3fdca368b
2 files changed
+3 -8

No files matched your search

@@ -547,8 +547,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
// Unused cache key if needed
val binaryId = cacheId ?: binaryPool.findUnusedKey().toString()
val fileInCache = File(cacheDirectory, binaryId)
val compressionBinary = compression ?: (compressionAlgorithm == CompressionAlgorithm.GZip)
val binaryAttachment = BinaryAttachment(fileInCache, protection, compressionBinary)
val binaryAttachment = BinaryAttachment(fileInCache, protection, compression)
// add attachment to pool
binaryPool.put(binaryId.toInt(), binaryAttachment)
return binaryAttachment
@@ -978,13 +978,9 @@ class DatabaseInputKDBX(cacheDirectory: File,
return null
val data = Base64.decode(base64, BASE_64_FLAG)
// Force compression in this specific case
val effectivelyCompressed = if (mDatabase.compressionAlgorithm == CompressionAlgorithm.GZip
&& !compressed) {
true
} else {
compressed
}
&& !compressed) true else compressed
val binaryAttachment = mDatabase.buildNewBinary(cacheDirectory, protected, effectivelyCompressed, binaryId)
binaryAttachment.getOutputDataStream().use { outputStream ->
// Force compression in this specific case