Fix resource leak

This commit is contained in:
Naveen Singh
2025-03-17 01:32:58 +05:30
parent 545fc855ed
commit 1cad5436ea

View File

@@ -869,17 +869,16 @@ class MainActivity : SimpleActivity() {
}
private fun checkUri(uri: Uri, onChecksPassed: () -> Unit) {
val inputStream = try {
contentResolver.openInputStream(uri) ?: return
try {
contentResolver.openInputStream(uri)?.use { inputStream ->
if (inputStream.available() > 1000 * 1000) {
toast(R.string.file_too_large)
} else {
onChecksPassed()
}
} ?: return
} catch (e: Exception) {
showErrorToast(e)
return
}
if (inputStream.available() > 1000 * 1000) {
toast(R.string.file_too_large)
} else {
onChecksPassed()
}
}