소스 검색

undo these changes that were carried over from outdated master

Cristiano Coelho 4 년 전
부모
커밋
8ee728e6c1
1개의 변경된 파일14개의 추가작업 그리고 3개의 파일을 삭제
  1. 14
    3
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 14
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java 파일 보기

578
                 }
578
                 }
579
                 break;
579
                 break;
580
             case FileStorage:
580
             case FileStorage:
581
+                ResponseBody responseBody = resp.body();
582
+
581
                 try {
583
                 try {
582
                     // In order to write response data to `destPath` we have to invoke this method.
584
                     // In order to write response data to `destPath` we have to invoke this method.
583
                     // It uses customized response body which is able to report download progress
585
                     // It uses customized response body which is able to report download progress
584
                     // and write response data to destination path.
586
                     // and write response data to destination path.
585
-                    resp.body().bytes();
587
+                    responseBody.bytes();
586
                 } catch (Exception ignored) {
588
                 } catch (Exception ignored) {
587
 //                    ignored.printStackTrace();
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
                 break;
602
                 break;
592
             default:
603
             default:
593
                 try {
604
                 try {