From e97f1a1040eafaed6d5284d54d33403dff215886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=C2=A0Koby=C5=82ko?= Date: Sat, 11 Nov 2023 16:07:07 +0100 Subject: [PATCH] Bump backup schema --- .../twofasapp/data/cloud/googledrive/GoogleDriveImpl.kt | 7 +++++-- .../com/twofasapp/data/services/domain/BackupContent.kt | 2 +- .../main/java/com/twofasapp/prefs/model/RemoteBackup.kt | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/data/cloud/src/main/java/com/twofasapp/data/cloud/googledrive/GoogleDriveImpl.kt b/data/cloud/src/main/java/com/twofasapp/data/cloud/googledrive/GoogleDriveImpl.kt index 4a4061b8..4eb6b687 100644 --- a/data/cloud/src/main/java/com/twofasapp/data/cloud/googledrive/GoogleDriveImpl.kt +++ b/data/cloud/src/main/java/com/twofasapp/data/cloud/googledrive/GoogleDriveImpl.kt @@ -31,6 +31,7 @@ internal class GoogleDriveImpl( companion object { private val backupVersions = listOf( + "2fas-backup-v4.json", "2fas-backup-v3.json", "2fas-backup-v2.json", "2fas-backup.json" @@ -46,10 +47,11 @@ internal class GoogleDriveImpl( ?: return@withContext GoogleDriveFileResult.Failure(error = GoogleDriveError.CredentialsNotFound) val drive = getDrive(credentials) - val backupFileId = getFiles(drive) + val backupFile = getFiles(drive) ?.filter { backupVersions.contains(it.name) } ?.firstOrNull() - ?.id + + val backupFileId = backupFile?.id if (backupFileId != null) { val fileContent = drive.files()[backupFileId]?.executeMediaAsInputStream()?.use { inputStream -> @@ -57,6 +59,7 @@ internal class GoogleDriveImpl( reader.readText() } } + Timber.d("GetFile <- ${backupFile.name}") Timber.d("GetFile <- \"$fileContent\"") Timber.d("GetFile <- Success") diff --git a/data/services/src/main/java/com/twofasapp/data/services/domain/BackupContent.kt b/data/services/src/main/java/com/twofasapp/data/services/domain/BackupContent.kt index 0d67fb78..961c3280 100644 --- a/data/services/src/main/java/com/twofasapp/data/services/domain/BackupContent.kt +++ b/data/services/src/main/java/com/twofasapp/data/services/domain/BackupContent.kt @@ -27,7 +27,7 @@ data class BackupContent( val reference: String? = null, ) { companion object { - const val CurrentSchema = 3 + const val CurrentSchema = 4 const val Reference = "tRViSsLKzd86Hprh4ceC2OP7xazn4rrt4xhfEUbOjxLX8Rc3mkISXE0lWbmnWfggogbBJhtYgpK6fMl1D6mtsy92R3HkdGfwuXbzLebqVFJsR7IZ2w58t938iymwG4824igYy1wi6n2WDpO1Q1P69zwJGs2F5a1qP4MyIiDSD7NCV2OvidXQCBnDlGfmz0f1BQySRkkt4ryiJeCjD2o4QsveJ9uDBUn8ELyOrESv5R5DMDkD4iAF8TXU7KyoJujd" diff --git a/prefs/src/main/java/com/twofasapp/prefs/model/RemoteBackup.kt b/prefs/src/main/java/com/twofasapp/prefs/model/RemoteBackup.kt index c2a32b33..2ffe83f1 100644 --- a/prefs/src/main/java/com/twofasapp/prefs/model/RemoteBackup.kt +++ b/prefs/src/main/java/com/twofasapp/prefs/model/RemoteBackup.kt @@ -27,8 +27,6 @@ data class RemoteBackup( val reference: String? = null, ) { companion object { - const val CURRENT_SCHEMA = 3 - - fun createEmpty() = RemoteBackup() + const val CURRENT_SCHEMA = 4 } } \ No newline at end of file