-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: bulletproofing crypto box to cc migration (WPB-14250) #3123
Merged
yamilmedina
merged 20 commits into
release/candidate
from
chore/bulletproofing-cc-migration-rc
Nov 26, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7abf566
feat: cleaning all data if failure
yamilmedina ef8e57a
feat: cleaning all data if failure
yamilmedina f873c5c
feat: clean up code
yamilmedina 8f12b41
feat: clean up code
yamilmedina 5e48155
chore: add plan b, logout user
yamilmedina 056faa6
chore: add plan b, logout user, cleanup code
yamilmedina 5acc6d9
chore: cleanup code
yamilmedina d30f5b8
chore: cleanup code
yamilmedina f57a1c6
chore: cleanup code detekt
yamilmedina 96e0c5d
chore: cleanup code detekt
yamilmedina 6e09dae
chore: remove exception for testing
yamilmedina dc6cf96
chore: tests for new branches
yamilmedina f8685a6
chore: tests for new branches
yamilmedina c9c072c
chore: solve layer issue
yamilmedina 2210a46
chore: more test covereage
yamilmedina 5eabef9
chore: layering
yamilmedina 20b3892
chore: solve missing reference
yamilmedina dca57d4
fix: deadlock while cleanup
yamilmedina a75ef06
fix: tests
yamilmedina 5b2361e
fix: tests detekt
yamilmedina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...rc/commonMain/kotlin/com/wire/kalium/logic/data/client/ProteusMigrationRecoveryHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.data.client | ||
|
||
import com.wire.kalium.logic.data.logout.LogoutReason | ||
|
||
/** | ||
* Handles the migration error of a proteus client storage from CryptoBox to CoreCrypto. | ||
* It will perform a logout, using [LogoutReason.MIGRATION_TO_CC_FAILED] as the reason. | ||
* | ||
* This achieves that the client data is cleared and the user is logged out without losing content. | ||
*/ | ||
interface ProteusMigrationRecoveryHandler { | ||
suspend fun clearClientData(clearLocalFiles: suspend () -> Unit) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...onMain/kotlin/com/wire/kalium/logic/feature/client/ProteusMigrationRecoveryHandlerImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.client | ||
|
||
import com.wire.kalium.logic.data.client.ProteusMigrationRecoveryHandler | ||
import com.wire.kalium.logic.data.logout.LogoutReason | ||
import com.wire.kalium.logic.feature.auth.LogoutUseCase | ||
import com.wire.kalium.logic.kaliumLogger | ||
|
||
internal class ProteusMigrationRecoveryHandlerImpl( | ||
private val logoutUseCase: Lazy<LogoutUseCase> | ||
) : ProteusMigrationRecoveryHandler { | ||
|
||
/** | ||
* Handles the migration error of a proteus client storage from CryptoBox to CoreCrypto. | ||
* It will perform a logout, using [LogoutReason.MIGRATION_TO_CC_FAILED] as the reason. | ||
* | ||
* This achieves that the client data is cleared and the user is logged out without losing content. | ||
*/ | ||
@Suppress("TooGenericExceptionCaught") | ||
override suspend fun clearClientData(clearLocalFiles: suspend () -> Unit) { | ||
try { | ||
kaliumLogger.withTextTag(TAG).i("Starting the recovery from failed Proteus storage migration") | ||
clearLocalFiles() | ||
logoutUseCase.value(LogoutReason.MIGRATION_TO_CC_FAILED, true) | ||
} catch (e: Exception) { | ||
kaliumLogger.withTextTag(TAG).e("Fatal, error while clearing client data: $e") | ||
throw e | ||
} finally { | ||
kaliumLogger.withTextTag(TAG).i("Finished the recovery from failed Proteus storage migration") | ||
} | ||
} | ||
|
||
private companion object { | ||
const val TAG = "ProteusMigrationRecoveryHandler" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion, maybe we should have some static error code variable to not duplicate codes in future?