Skip to content

Commit aca9058

Browse files
committed
Fix joltup#170 - RNFetchBlob fs hash with md5 param fails if the file size is 0(blank)
1 parent 085db09 commit aca9058

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,11 @@ static void hash(String path, String algorithm, Promise promise) {
878878
FileInputStream inputStream = new FileInputStream(path);
879879
byte[] buffer = new byte[(int)file.length()];
880880

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+
}
884886
}
885887

886888
StringBuilder hexString = new StringBuilder();

0 commit comments

Comments
 (0)