Bump backup schema

This commit is contained in:
Rafał Kobyłko 2023-11-11 16:07:07 +01:00
parent 0d5b902ba8
commit e97f1a1040
3 changed files with 7 additions and 6 deletions

View File

@ -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")

View File

@ -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"

View File

@ -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
}
}