Skip to content

Commit 0914c23

Browse files
authored
fix(android): Prevent Android 10 crash on Filesystem.readdir (#2950)
1 parent b8e7279 commit 0914c23

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

android/capacitor/src/main/java/com/getcapacitor/plugin/Filesystem.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,13 @@ public void readdir(PluginCall call) {
412412
|| isStoragePermissionGranted(PluginRequestCodes.FILESYSTEM_REQUEST_READ_FOLDER_PERMISSIONS, Manifest.permission.READ_EXTERNAL_STORAGE)) {
413413
if (fileObject != null && fileObject.exists()) {
414414
String[] files = fileObject.list();
415-
416-
JSObject ret = new JSObject();
417-
ret.put("files", JSArray.from(files));
418-
call.success(ret);
415+
if (files != null) {
416+
JSObject ret = new JSObject();
417+
ret.put("files", JSArray.from(files));
418+
call.success(ret);
419+
} else {
420+
call.error("Unable to read directory");
421+
}
419422
} else {
420423
call.error("Directory does not exist");
421424
}

0 commit comments

Comments
 (0)