Browse Source

Revert "Merge pull request #396 from sonudoo/download-interruption-android-bugfix"

This reverts commit 4305ef8175, reversing
changes made to d35fb73424.
Travis Nuttall 5 years ago
parent
commit
0e2c40e69b

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

530
                 }
530
                 }
531
                 break;
531
                 break;
532
             case FileStorage:
532
             case FileStorage:
533
-                ResponseBody responseBody = resp.body();
534
-
535
                 try {
533
                 try {
536
                     // In order to write response data to `destPath` we have to invoke this method.
534
                     // In order to write response data to `destPath` we have to invoke this method.
537
                     // It uses customized response body which is able to report download progress
535
                     // It uses customized response body which is able to report download progress
538
                     // and write response data to destination path.
536
                     // and write response data to destination path.
539
-                    responseBody.bytes();
537
+                    resp.body().bytes();
540
                 } catch (Exception ignored) {
538
                 } catch (Exception ignored) {
541
 //                    ignored.printStackTrace();
539
 //                    ignored.printStackTrace();
542
                 }
540
                 }
543
-
544
-                RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
545
-
546
-                if(rnFetchBlobFileResp != null && rnFetchBlobFileResp.isDownloadComplete() == false){
547
-                    callback.invoke("RNFetchBlob failed. Download interrupted.", null);
548
-                }
549
-                else {
550
-                    this.destPath = this.destPath.replace("?append=true", "");
551
-                    callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
552
-                }
541
+                this.destPath = this.destPath.replace("?append=true", "");
542
+                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
553
                 break;
543
                 break;
554
             default:
544
             default:
555
                 try {
545
                 try {

+ 0
- 4
android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java View File

68
         return originalBody.contentLength();
68
         return originalBody.contentLength();
69
     }
69
     }
70
 
70
 
71
-    public boolean isDownloadComplete() {
72
-        return bytesDownloaded == contentLength();
73
-    }
74
-
75
     @Override
71
     @Override
76
     public BufferedSource source() {
72
     public BufferedSource source() {
77
         ProgressReportingSource countable = new ProgressReportingSource();
73
         ProgressReportingSource countable = new ProgressReportingSource();