Browse Source

undo these changes that were carried over from outdated master

Cristiano Coelho 4 years ago
parent
commit
8ee728e6c1
1 changed files with 14 additions and 3 deletions
  1. 14
    3
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 14
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

@@ -578,16 +578,27 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
578 578
                 }
579 579
                 break;
580 580
             case FileStorage:
581
+                ResponseBody responseBody = resp.body();
582
+
581 583
                 try {
582 584
                     // In order to write response data to `destPath` we have to invoke this method.
583 585
                     // It uses customized response body which is able to report download progress
584 586
                     // and write response data to destination path.
585
-                    resp.body().bytes();
587
+                    responseBody.bytes();
586 588
                 } catch (Exception ignored) {
587 589
 //                    ignored.printStackTrace();
588 590
                 }
589
-                this.destPath = this.destPath.replace("?append=true", "");
590
-                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
591
+
592
+                RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
593
+
594
+                if(rnFetchBlobFileResp != null && !rnFetchBlobFileResp.isDownloadComplete()){
595
+                    callback.invoke("RNFetchBlob failed. Download interrupted.", null);
596
+                }
597
+                else {
598
+                    this.destPath = this.destPath.replace("?append=true", "");
599
+                    callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
600
+                }
601
+
591 602
                 break;
592 603
             default:
593 604
                 try {