Skip to content

Commit abb8272

Browse files
authored
Merge pull request #347 from jacargentina/master
Fix for #346: compressed file assets are detected as directories
2 parents 252cd5a + 18ee5b3 commit abb8272

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

android/src/main/java/com/rnfs/RNFSManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,17 @@ public void readDirAssets(String directory, Promise promise) {
342342
String path = directory.isEmpty() ? childFile : String.format("%s/%s", directory, childFile); // don't allow / at the start when directory is ""
343343
fileMap.putString("path", path);
344344
int length = 0;
345-
boolean isDirectory = false;
345+
boolean isDirectory = true;
346346
try {
347347
AssetFileDescriptor assetFileDescriptor = assetManager.openFd(path);
348348
if (assetFileDescriptor != null) {
349349
length = (int) assetFileDescriptor.getLength();
350350
assetFileDescriptor.close();
351+
isDirectory = false;
351352
}
352353
} catch (IOException ex) {
353-
//.. ah.. is a directory!
354-
isDirectory = true;
354+
//.. ah.. is a directory or a compressed file?
355+
isDirectory = ex.getMessage().indexOf("compressed") == -1;
355356
}
356357
fileMap.putInt("size", length);
357358
fileMap.putInt("type", isDirectory ? 1 : 0); // if 0, probably a folder..

0 commit comments

Comments
 (0)