alexrintt / shared-storage

Flutter plugin to work with Android external storage.
http://alexrintt.io/shared-storage/
MIT License
54 stars 26 forks source link

Use of listFiles() without the ID column results in a null pointer casting crash. #50

Closed EternityForest closed 2 years ago

EternityForest commented 2 years ago

Describe the bug Specifically, we get an error trying to cast a null to a Kotlin String on that appears to be from line 212(https://github.com/lakscastro/shared-storage/blob/1bfeb88df69938c62d7709861cc426ec71515f3c/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt), if one tries to iterate anything without enabling the id column.

val id =
          data[DocumentsContract.Document.COLUMN_DOCUMENT_ID] as String

Seems to be the culprit line.

I'm not actually sure this is really a bug, it might be simpler just to document that the Id column is needed.

alexrintt commented 2 years ago

Indeed it is. I'll update the docs to something like: 'Id is optional, since it'll be queried even when not explicity requested'.

I pushed some commits to make it optional.

Thanks, @EternityForest!

alexrintt commented 2 years ago

@all-contributors please add @EternityForest for bug

allcontributors[bot] commented 2 years ago

@lakscastro

I've put up a pull request to add @EternityForest! :tada:

alexrintt commented 2 years ago

Fixed by #52, #53 and published by #54.

If you have anything to add, you can reopen this issue.

If you found a new bug, you can open a new issue.

Thanks!