Skip to content

Commit

Permalink
chore: improve logging for backups (WPB-12113) (#3093)
Browse files Browse the repository at this point in the history
* chore: improve logging for backups

* chore: improve logging for backups

* chore: detekt
  • Loading branch information
yamilmedina authored Nov 7, 2024
1 parent b7bdcea commit 83207c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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

0 comments on commit 83207c7

Please sign in to comment.