Skip to content

Error: Value must be ? 0 but getColumnIndex can be -1 [Range] #891

@beautifulboy11

Description

@beautifulboy11

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch rn-fetch-blob@0.12.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
index a8abd71..990ad65 100644
--- a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
+++ b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
@@ -738,7 +738,9 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
                     // the file exists in media content database
                     if (c.moveToFirst()) {
                         // #297 handle failed request
-                        int statusCode = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
+                        //int statusCode = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
+                        int statusCol = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
+                        int statusCode = statusCol != -1 ? c.getInt(statusCol) : DownloadManager.STATUS_FAILED;
                         if(statusCode == DownloadManager.STATUS_FAILED) {
                             this.callback.invoke("Download manager failed to download from  " + this.url + ". Status Code = " + statusCode, null, null);
                             return;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions