diff --git a/app/src/main/java/se/ajpanton/notificationlog/data/EncryptedNotificationLogStore.kt b/app/src/main/java/se/ajpanton/notificationlog/data/EncryptedNotificationLogStore.kt index 36e26be..ccca54f 100644 --- a/app/src/main/java/se/ajpanton/notificationlog/data/EncryptedNotificationLogStore.kt +++ b/app/src/main/java/se/ajpanton/notificationlog/data/EncryptedNotificationLogStore.kt @@ -40,13 +40,13 @@ class EncryptedNotificationLogStore(context: Context) { val payload = cipher.encrypt(NotificationLogEntryJson.encode(entries)) val output = file.startWrite() try { - DataOutputStream(BufferedOutputStream(output)).use { stream -> - stream.writeInt(FILE_VERSION) - stream.writeInt(payload.initializationVector.size) - stream.write(payload.initializationVector) - stream.writeInt(payload.cipherText.size) - stream.write(payload.cipherText) - } + val stream = DataOutputStream(BufferedOutputStream(output)) + stream.writeInt(FILE_VERSION) + stream.writeInt(payload.initializationVector.size) + stream.write(payload.initializationVector) + stream.writeInt(payload.cipherText.size) + stream.write(payload.cipherText) + stream.flush() file.finishWrite(output) } catch (error: Exception) { file.failWrite(output)