code review

This commit is contained in:
Valere 2021-12-08 15:47:06 +01:00
parent 01b8b7d57a
commit a026137381
1 changed files with 2 additions and 5 deletions

View File

@ -46,7 +46,6 @@ internal class OneTimeKeysUploader @Inject constructor(
// last OTK check timestamp // last OTK check timestamp
private var lastOneTimeKeyCheck: Long = 0 private var lastOneTimeKeyCheck: Long = 0
private var oneTimeKeyCount: Int? = null private var oneTimeKeyCount: Int? = null
private var needNewFallbackKey: Boolean = false
// Simple storage to remember when was uploaded the last fallback key // Simple storage to remember when was uploaded the last fallback key
private val storage = context.getSharedPreferences("OneTimeKeysUploader_${olmDevice.deviceEd25519Key.hashCode()}", Context.MODE_PRIVATE) private val storage = context.getSharedPreferences("OneTimeKeysUploader_${olmDevice.deviceEd25519Key.hashCode()}", Context.MODE_PRIVATE)
@ -93,7 +92,7 @@ internal class OneTimeKeysUploader @Inject constructor(
Timber.w("maybeUploadOneTimeKeys: Failed to get otk count from server") Timber.w("maybeUploadOneTimeKeys: Failed to get otk count from server")
} }
Timber.d("maybeUploadOneTimeKeys: otk count $oneTimeKeyCountFromSync , needs fallback key $needNewFallbackKey") Timber.d("maybeUploadOneTimeKeys: otk count $oneTimeKeyCountFromSync , unpublished fallback key ${olmDevice.hasUnpublishedFallbackKey()}")
lastOneTimeKeyCheck = System.currentTimeMillis() lastOneTimeKeyCheck = System.currentTimeMillis()
@ -150,7 +149,7 @@ internal class OneTimeKeysUploader @Inject constructor(
* @return the number of uploaded keys * @return the number of uploaded keys
*/ */
private suspend fun uploadOTK(keyCount: Int, keyLimit: Int): Int { private suspend fun uploadOTK(keyCount: Int, keyLimit: Int): Int {
if (keyLimit <= keyCount && !needNewFallbackKey) { if (keyLimit <= keyCount && !olmDevice.hasUnpublishedFallbackKey()) {
// If we don't need to generate any more keys then we are done. // If we don't need to generate any more keys then we are done.
return 0 return 0
} }
@ -172,8 +171,6 @@ internal class OneTimeKeysUploader @Inject constructor(
saveLastFallbackKeyPublishTime(System.currentTimeMillis()) saveLastFallbackKeyPublishTime(System.currentTimeMillis())
} }
needNewFallbackKey = false
if (response.hasOneTimeKeyCountsForAlgorithm(MXKey.KEY_SIGNED_CURVE_25519_TYPE)) { if (response.hasOneTimeKeyCountsForAlgorithm(MXKey.KEY_SIGNED_CURVE_25519_TYPE)) {
// Maybe upload other keys // Maybe upload other keys
return keysThisLoop + return keysThisLoop +