소스 검색

Merge pull request #423 from ankit-makwana/hash-fix

Fix #170 - RNFetchBlob fs hash with md5 param fails if the file size is 0(blank file)
Travis Nuttall 4 년 전
부모
커밋
b25baab96c
No account linked to committer's email address
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5
    3
      android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+ 5
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java 파일 보기

@@ -895,9 +895,11 @@ class RNFetchBlobFS {
895 895
             int chunkSize = 4096 * 256; // 1Mb
896 896
             byte[] buffer = new byte[chunkSize];
897 897
 
898
-            int bytesRead;
899
-            while ((bytesRead = inputStream.read(buffer)) != -1) {
900
-                md.update(buffer, 0, bytesRead);
898
+            if(file.length() != 0) {
899
+                int bytesRead;
900
+                while ((bytesRead = inputStream.read(buffer)) != -1) {
901
+                    md.update(buffer, 0, bytesRead);
902
+                }
901 903
             }
902 904
 
903 905
             StringBuilder hexString = new StringBuilder();