Skip to content

Commit

Permalink
build: Release 0.27.1(306) #1208
Browse files Browse the repository at this point in the history
  • Loading branch information
igordanilcenko authored Sep 16, 2024
2 parents 5641dba + 676e98c commit 363e07f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,27 @@ package com.tari.android.wallet.application

import com.tari.android.wallet.BuildConfig
import com.tari.android.wallet.application.walletManager.WalletManager
import com.tari.android.wallet.data.sharedPrefs.network.NetworkPrefRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.apache.maven.artifact.versioning.DefaultArtifactVersion
import java.io.File
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class MigrationManager @Inject constructor(
private val walletManager: WalletManager,
private val application: TariWalletApplication,
private val networkRepository: NetworkPrefRepository,
) {

suspend fun validateVersion(onValid: () -> Unit, onError: () -> Unit) {
val walletVersion = getCurrentWalletVersion()

// FIXME: Temporary migration mechanism. It should be removed when minValidVersion is greater than 1.0.0-rc.8
if (walletVersion.isNotEmpty() && DefaultArtifactVersion(walletVersion) < DefaultArtifactVersion(PEER_DB_MIGRATION_MIN_VERSION)) {
performPeerDbMigration()
}

if (walletVersion.isEmpty() || DefaultArtifactVersion(walletVersion) < DefaultArtifactVersion(BuildConfig.LIB_WALLET_MIN_VALID_VERSION)) {
suspend fun validateVersion(onValid: () -> Unit, onError: () -> Unit) = withContext(Dispatchers.IO) {
val walletVersion = walletManager.getCommsConfig().getLastVersion()
.replace("v", "")
.takeIf { it.isNotEmpty() }
?.let { DefaultArtifactVersion(it) }
val minValidVersion = DefaultArtifactVersion(BuildConfig.LIB_WALLET_MIN_VALID_VERSION.replace("v", ""))

if (walletVersion == null || walletVersion < minValidVersion) {
onError()
} else {
onValid()
}
}

private suspend fun getCurrentWalletVersion(): String = withContext(Dispatchers.IO) { walletManager.getCommsConfig().getLastVersion() }

private suspend fun performPeerDbMigration() = withContext(Dispatchers.IO) {
application.applicationInfo.dataDir?.let { appDir ->
val peerDbFile = File(appDir, "files/${networkRepository.currentNetwork.network.uriComponent}/data.mdb")
if (peerDbFile.exists()) {
peerDbFile.delete()
}
}
}

companion object {
const val PEER_DB_MIGRATION_MIN_VERSION = "1.0.0-rc.8"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.tari.android.wallet.ui.fragment.auth

import androidx.lifecycle.viewModelScope
import com.tari.android.wallet.R
import com.tari.android.wallet.application.MigrationManager
import com.tari.android.wallet.extension.launchOnIo
import com.tari.android.wallet.extension.launchOnMain
import com.tari.android.wallet.infrastructure.security.biometric.BiometricAuthenticationService
import com.tari.android.wallet.service.service.WalletServiceLauncher
import com.tari.android.wallet.ui.common.CommonViewModel
Expand All @@ -12,8 +13,6 @@ import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonModule
import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonStyle
import com.tari.android.wallet.ui.dialog.modular.modules.head.HeadModule
import com.tari.android.wallet.ui.fragment.home.navigation.Navigation
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

class AuthViewModel : CommonViewModel() {
Expand All @@ -32,15 +31,15 @@ class AuthViewModel : CommonViewModel() {
init {
component.inject(this)

viewModelScope.launch(Dispatchers.IO) {
launchOnIo {
migrationManager.validateVersion(
onValid = {
viewModelScope.launch(Dispatchers.Main) {
launchOnMain {
goAuth.postValue(Unit)
}
},
onError = {
viewModelScope.launch(Dispatchers.Main) {
launchOnMain {
showIncompatibleVersionDialog()
}
}
Expand All @@ -65,7 +64,7 @@ class AuthViewModel : CommonViewModel() {

private fun deleteWallet() {
// disable CTAs
viewModelScope.launch(Dispatchers.IO) {
launchOnIo {
walletServiceLauncher.stopAndDelete()
navigation.postValue(Navigation.TxListNavigation.ToSplashScreen)
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
ext.coroutines_version = '1.8.0'

// build & version
ext.buildNumber = 304
ext.versionNumber = "0.27.0"
ext.buildNumber = 306
ext.versionNumber = "0.27.1"

// JNI libs
ext.libwalletHostURL = "https://github.com/tari-project/tari/releases/download/"
Expand Down

0 comments on commit 363e07f

Please sign in to comment.