Skip to content

Commit 09ea310

Browse files
fix: Properly initializing Cursor for content URIs
1 parent 594a296 commit 09ea310

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/kotlin/io/ionic/libs/ionfiletransferlib/helpers/IONFLTRFileHelper.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ internal class IONFLTRFileHelper(val contentResolver: ContentResolver) {
2626
fun getFileToUploadInfo(filePath: String): FileToUploadInfo {
2727
return if (filePath.startsWith("content://")) {
2828
val uri = filePath.toUri()
29-
val cursor = contentResolver.query(uri, null, null, null, null)
30-
?: throw IONFLTRException.FileDoesNotExist()
29+
val cursor = contentResolver.query(uri, null, null, null, null)
30+
if (cursor?.moveToFirst() != true) {
31+
throw IONFLTRException.FileDoesNotExist()
32+
}
3133
cursor.use {
3234
val fileName = getNameForContentUri(cursor)
3335
?: throw IONFLTRException.FileDoesNotExist()

0 commit comments

Comments
 (0)