Skip to content

Commit

Permalink
Merge pull request #224 from Infomaniak/fix-open-input-stream-crash
Browse files Browse the repository at this point in the history
fix: Catch openInputStream crash and count it as a "failed file"
  • Loading branch information
sirambd authored Dec 2, 2024
2 parents 0881f0d + beef9af commit 23448c9
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ class ImportationFilesManager @Inject constructor(
}

private fun openInputStream(uri: Uri): InputStream? {
return appContext.contentResolver.openInputStream(uri) ?: run {
SentryLog.w(ImportLocalStorage.TAG, "During local copy of the file openInputStream returned null")
null
}
return runCatching { appContext.contentResolver.openInputStream(uri) }
.onSuccess {
if (it == null) SentryLog.w(ImportLocalStorage.TAG, "During local copy of the file openInputStream returned null")
}
.getOrNull()
}

private fun getRestoredFileUi(localFiles: Array<File>): List<FileUi> {
Expand Down

0 comments on commit 23448c9

Please sign in to comment.