Preserve atomic encrypted log writes
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user