Skip to content
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: improve logging for backups (WPB-12113) #3093

Merged
merged 3 commits into from
Nov 7, 2024
Merged
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 @@ -95,7 +95,13 @@ internal class RestoreBackupUseCaseImpl(
importEncryptedBackup(extractedBackupRootPath, password)
}
}
.fold({ it }, { RestoreBackupResult.Success })
.fold({ error ->
kaliumLogger.e("$TAG Failed to restore the backup, reason: ${error.failure}")
error
}, {
kaliumLogger.i("$TAG Backup restored successfully")
RestoreBackupResult.Success
})
}

private suspend fun importUnencryptedBackup(
Expand Down Expand Up @@ -140,7 +146,7 @@ internal class RestoreBackupUseCaseImpl(
val extractedFilesRootPath = createExtractedFilesRootPath()
return extractFiles(tempCompressedFileSource, extractedFilesRootPath)
.fold({
kaliumLogger.e("Failed to extract backup files")
kaliumLogger.e("$TAG Failed to extract backup files")
Either.Left(Failure(BackupIOFailure("Failed to extract backup files")))
}, {
Either.Right(extractedFilesRootPath)
Expand Down Expand Up @@ -176,7 +182,7 @@ internal class RestoreBackupUseCaseImpl(
return if (backupSize > 0) {
// On successful decryption, we still need to extract the zip file to do sanity checks and get the database file
extractFiles(kaliumFileSystem.source(extractedBackupPath), extractedBackupRootPath).fold({
kaliumLogger.e("Failed to extract encrypted backup files")
kaliumLogger.e("$TAG Failed to extract encrypted backup files")
Either.Left(Failure(BackupIOFailure("Failed to extract encrypted backup files")))
}, {
kaliumFileSystem.delete(extractedBackupPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ internal class RestoreWebBackupUseCaseImpl(
importWebBackup(backupRootPath, this)
} else {
Either.Left(IncompatibleBackup("invoke: The provided backup format is not supported"))
}.fold({ RestoreBackupResult.Failure(it) }, { RestoreBackupResult.Success })
}.fold({ error ->
kaliumLogger.e("$TAG Failed to restore the backup, reason: $error")
RestoreBackupResult.Failure(error)
}, {
kaliumLogger.i("$TAG Successfully restored the backup")
RestoreBackupResult.Success
})
}

private suspend fun importWebBackup(
Expand Down
Loading