Przeglądaj źródła

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

Ankit Makwana 4 lat temu
rodzic
commit
aca905853f

+ 5
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java Wyświetl plik

@@ -878,9 +878,11 @@ class RNFetchBlobFS {
878 878
             FileInputStream inputStream = new FileInputStream(path);
879 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 888
             StringBuilder hexString = new StringBuilder();