diff --git a/app/src/main/java/com/anytypeio/anytype/ui/update/MigrationErrorScreen.kt b/app/src/main/java/com/anytypeio/anytype/ui/update/MigrationErrorScreen.kt
index 509d784f6a..e7340f15e9 100644
--- a/app/src/main/java/com/anytypeio/anytype/ui/update/MigrationErrorScreen.kt
+++ b/app/src/main/java/com/anytypeio/anytype/ui/update/MigrationErrorScreen.kt
@@ -303,8 +303,8 @@ fun MigrationFailedScreen(
onRetryClicked: () -> Unit
) {
val description = when(state) {
- MigrationHelperDelegate.State.Failed.NotEnoughSpace -> {
- stringResource(R.string.migration_error_please_free_up_space_and_run_the_process_again)
+ is MigrationHelperDelegate.State.Failed.NotEnoughSpace -> {
+ stringResource(R.string.migration_error_please_free_up_space_and_run_the_process_again, state.requiredSpaceInMegabytes)
}
is MigrationHelperDelegate.State.Failed.UnknownError -> {
state.error.message ?: stringResource(R.string.unknown_error)
@@ -382,7 +382,7 @@ fun MigrationInProgressScreenPreview() {
@Composable
fun MigrationFailedScreenPreview() {
MigrationFailedScreen(
- state = MigrationHelperDelegate.State.Failed.NotEnoughSpace,
+ state = MigrationHelperDelegate.State.Failed.NotEnoughSpace(450),
onRetryClicked = {}
)
}
diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/AccountIsDeletedException.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/AccountIsDeletedException.kt
index a9b78e1f66..99c68bc662 100644
--- a/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/AccountIsDeletedException.kt
+++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/AccountIsDeletedException.kt
@@ -5,5 +5,5 @@ class NeedToUpdateApplicationException: Exception()
class AccountMigrationNeededException: Exception()
sealed class MigrationFailedException : Exception() {
- class NotEnoughSpace : MigrationFailedException()
+ data class NotEnoughSpace(val requiredSpaceInBytes: Long) : MigrationFailedException()
}
\ No newline at end of file
diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml
index 741df93c52..1dad3543b7 100644
--- a/localization/src/main/res/values/strings.xml
+++ b/localization/src/main/res/values/strings.xml
@@ -1922,7 +1922,7 @@ Please provide specific details of your needs here.
This may take some time. Please don’t close the app until the process is complete.
Try again
Migration failed
- Please free up space and run the process again.
+ Please clear ≈ %1$s MB of space and run the process again
Properties
Text
diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/service/MiddlewareServiceImplementation.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/service/MiddlewareServiceImplementation.kt
index 6121f8448b..68a7792677 100644
--- a/middleware/src/main/java/com/anytypeio/anytype/middleware/service/MiddlewareServiceImplementation.kt
+++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/service/MiddlewareServiceImplementation.kt
@@ -116,7 +116,7 @@ class MiddlewareServiceImplementation @Inject constructor(
if (error != null && error.code != Rpc.Account.Migrate.Response.Error.Code.NULL) {
when(error.code) {
Rpc.Account.Migrate.Response.Error.Code.NOT_ENOUGH_FREE_SPACE -> {
- throw MigrationFailedException.NotEnoughSpace()
+ throw MigrationFailedException.NotEnoughSpace(error.requiredSpace)
}
else -> throw Exception(error.description)
}
diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/auth/account/MigrationHelperDelegate.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/auth/account/MigrationHelperDelegate.kt
index 56aba42a49..9200c66273 100644
--- a/presentation/src/main/java/com/anytypeio/anytype/presentation/auth/account/MigrationHelperDelegate.kt
+++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/auth/account/MigrationHelperDelegate.kt
@@ -5,9 +5,7 @@ import com.anytypeio.anytype.domain.auth.interactor.MigrateAccount
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.base.Resultat
import javax.inject.Inject
-import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
@@ -26,8 +24,11 @@ interface MigrationHelperDelegate {
.map { result ->
when(result) {
is Resultat.Failure -> {
- if (result.exception is MigrationFailedException.NotEnoughSpace) {
- State.Failed.NotEnoughSpace
+ val exception = result.exception
+ if (exception is MigrationFailedException.NotEnoughSpace) {
+ State.Failed.NotEnoughSpace(
+ requiredSpaceInMegabytes = (exception.requiredSpaceInBytes / 1_048_576)
+ )
} else {
State.Failed.UnknownError(result.exception)
}
@@ -45,7 +46,7 @@ interface MigrationHelperDelegate {
data object InProgress : State()
sealed class Failed : State() {
data class UnknownError(val error: Throwable) : Failed()
- data object NotEnoughSpace : Failed()
+ data class NotEnoughSpace(val requiredSpaceInMegabytes: Long) : Failed()
}
data object Migrated : State()
}