Skip to content

Commit

Permalink
Fix #2652 crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jun 19, 2023
1 parent eb54542 commit 9b15979
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,23 @@ class InstallZip : ActivityBase() {
it.moveToFirst()
val displayNameIdx = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
val mimeTypeIdx = it.getColumnIndex("mime_type")
Pair(it.getString(displayNameIdx), it.getString(mimeTypeIdx))
Pair(
if(displayNameIdx < 0) null else it.getString(displayNameIdx),
if(mimeTypeIdx < 0) null else it.getString(mimeTypeIdx)
)
}?: throw CantRead()

if (
displayName.lowercase().endsWith(".zip")
|| displayName.lowercase().endsWith(".abmd")
displayName?.lowercase()?.endsWith(".zip") == true
|| displayName?.lowercase()?.endsWith(".abmd") == true
|| mimeType == "application/zip"
)
return installZip(uri)

val filetype = when {
displayName.lowercase().endsWith(".sqlite3") -> "mybible"
displayName.lowercase().endsWith(".mybible") -> "mysword"
else -> throw InvalidFile(displayName)
displayName?.lowercase()?.endsWith(".sqlite3") == true -> "mybible"
displayName?.lowercase()?.endsWith(".mybible") == true -> "mysword"
else -> throw InvalidFile(displayName?: uri.toString())
}

binding.loadingIndicator.visibility = View.VISIBLE
Expand Down

0 comments on commit 9b15979

Please sign in to comment.