Fetch: request.setEnqueueAction(EnqueueAction.REPLACE_EXISTING)

Created on 7 Aug 2018  路  14Comments  路  Source: tonyofrancis/Fetch

I used request.setEnqueueAction(EnqueueAction.REPLACE_EXISTING); but this is not working for my case,
i want to download again (Re-download) the same files for some reasons. but when i going to re-download same files from same url , then it is actually not downloading , showing only progress bar. but without any progress . i am using rx-fetch to download multiple file with enqueue.
i am following your sample to get expected results and what i did in my app.

app.gradle
implementation "com.tonyodev.fetch2rx:fetch2rx:2.2.0-RC4"

App.java (application class)

final FetchConfiguration fetchConfiguration = new FetchConfiguration.Builder(this)
.enableRetryOnNetworkGain(true)
.setDownloadConcurrentLimit(3)
.setHttpDownloader(new HttpUrlConnectionDownloader(Downloader.FileDownloaderType.PARALLEL))
.build();
Fetch.Impl.setDefaultInstanceConfiguration(fetchConfiguration);
RxFetch.Impl.setDefaultRxInstanceConfiguration(fetchConfiguration);

and this for making queue of urls

GameFilesActivity.class

request.setPriority(Priority.HIGH);
mListRequests.add(request);
requestId = request.getId();

i just want to remove saved request id from your server and want to download again . please help me urgently
thanx for awsome library.

bug

All 14 comments

if i unistalling the app and re-install again and also deleting files from internal memory , then it is downloading the files again otherwise not ?

try to delete the request first, then enqueue again, that is how I am doing it.
Beware, delete is different from cancel, delete will delete request and its id and its files, cancel will keep the request and it state in the database, if I understood it correctly

This is how I am doing.
```
mFetch.delete(existingDownloadedId);
mFetch.enqueue(getFetchRequest(url, fileName, grpId, true),
updatedRequests -> {

            },
            error -> {
                Toast.makeText(this, error.toString(), Toast.LENGTH_SHORT).show();
            }
    );

```

@Ramkesh9 looking into this issue

found the bug working on a fix

@tonyofrancis thanx for review, please fix this bug 馃憤

@tonyofrancis actually i have some urgency's of work, so if you are able fix it in asap ,then it would be big help for me :)

i also tried to opt :

 if (completedFiles == totalFiles) {

        rxFetch.removeAll();
        fetch.remove(requestId);
        rxFetch.remove(requestId);

    }

with
requestId = request.getId();
request.setEnqueueAction(EnqueueAction.REPLACE_EXISTING);

the coming request id is : -238833965

and response is coming as :

android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: requests._id (code 1555)
and also decoded value message : REQUEST_WITH_ID_ALREADY_EXIST

please check it and let me know if any fix you have found :)
Thanx

@Ramkesh9 Just released Fetch 2.2.0-RC5 with this fix. Please let me know if it works well for you.

Yes, off course i will let you know within few hours, it was nice to see you fix the bug instantly,

@tonyofrancis
i updated implementation "com.tonyodev.fetch2rx:fetch2rx:2.2.0-RC5" and tried .

but same issue is coming with (REQUEST_WITH_ID_ALREADY_EXIST)

here few id's i noted while printing through this method
requestId = request.getId();
id's are :
-1824981677
-1901223219
345307347
-2063118413

i using this method for request :

final Request request = new Request(imgUrl, filePath);
request.setEnqueueAction(EnqueueAction.REPLACE_EXISTING);
request.setPriority(Priority.HIGH);
mListRequests.add(request);
requestId = request.getId();

Please help me with some solution, today their is big urgency for me to deliver.

@Ramkesh9 Which enqueue method are you using. fetch.enqueue(request, func, func) or fetch.enqueue(requestList, func, func)?. If you are using the second method and a request in the list does not have replace existing all the others will fail. If you want to send your full code to me via email. you can get my email on my profile. That way I can better help.

@Ramkesh9 I was finally able to replicate your actual issue. The error occurs when you have a list of requests that contains two or more request with the same url and file and you use fetch.enqueue(requestList, func, func). I have a fix and it will make it in RC6. The work around right now is to use the fetch.enqueue(request, func, func) and enqueue each request 1 at a time.

@Ramkesh9 Just released Fetch 2.2.0-RC6 with fixes. Please let me know if it works well for you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MohammadFneish7 picture MohammadFneish7  路  4Comments

jpvs0101 picture jpvs0101  路  5Comments

cepero91 picture cepero91  路  4Comments

rs-georg picture rs-georg  路  4Comments

Moeinh77 picture Moeinh77  路  4Comments