Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
*/
package com.infomaniak.core.auth.backup

object BlockStoreBackup {
const val isSupported: Boolean = false
class BlockStoreBackup(context: Context) {

companion object {
const val isSupported: Boolean = false
}

suspend fun backupTokens(): Boolean = false
suspend fun restoreTokens(): Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import com.infomaniak.core.auth.room.UserDatabase
import com.infomaniak.core.common.backup.FullBackupAgent
import kotlinx.coroutines.runBlocking

context(_: FullBackupAgent)
context(backupAgent: FullBackupAgent)
inline fun withBlockStoreCredentialsBackup(
crossinline backupCredentials: suspend () -> Boolean = { BlockStoreBackup.backupTokens() },
crossinline backupCredentials: suspend () -> Boolean = { BlockStoreBackup(backupAgent).backupTokens() },
crossinline defaultBackupCalls: () -> Unit
): Unit = runBlocking {
if (BlockStoreBackup.isSupported.not()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.infomaniak.core.auth.backup

import android.content.Context
import androidx.collection.LongObjectMap
import androidx.collection.buildLongObjectMap
import androidx.room.immediateTransaction
Expand All @@ -29,17 +30,17 @@ import com.infomaniak.core.auth.room.UserDatabase
import com.infomaniak.core.common.cancellable
import com.infomaniak.core.sentry.SentryLog
import kotlinx.coroutines.tasks.await
import splitties.init.appCtx

object BlockStoreBackup {
class BlockStoreBackup(context: Context) {

private const val TAG = "BlockStoreBackup"
companion object {
const val isSupported: Boolean = true
private const val TAG = "BlockStoreBackup"
}

private val blockstoreClient = Blockstore.getClient(appCtx)
private val blockstoreClient = Blockstore.getClient(context)
private val db = UserDatabase.instance

const val isSupported: Boolean = true

suspend fun backupTokens(): Boolean {
val backupContent = dumpTokens()
val alreadyBackedUpContent = readTokensBackup()
Expand Down
Loading