Browse Source

Fix #170 - RNFetchBlob fs hash with md5 param fails if the file size is 0(blank)

Ankit Makwana 5 years ago
parent
commit
aca905853f
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+ 5
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java View File

878
             FileInputStream inputStream = new FileInputStream(path);
878
             FileInputStream inputStream = new FileInputStream(path);
879
             byte[] buffer = new byte[(int)file.length()];
879
             byte[] buffer = new byte[(int)file.length()];
880
 
880
 
881
-            int read;
882
-            while ((read = inputStream.read(buffer)) != -1) {
883
-                md.update(buffer, 0, read);
881
+            if(file.length() != 0) {
882
+                int read;
883
+                while ((read = inputStream.read(buffer)) != -1) {
884
+                    md.update(buffer, 0, read);
885
+                }
884
             }
886
             }
885
 
887
 
886
             StringBuilder hexString = new StringBuilder();
888
             StringBuilder hexString = new StringBuilder();