Removing requests from database when completed.
See original GitHub issueHi,
I have two questions.
- How to download a file twice with same url and file path? For example there is a song under url = “www.url.com/newSet.mp3” and I want to save it to “…/DOWNLOAD_PATH/newSet” path. User fetched the file for the first time…then deleted it…and then fetched again. Unfortunately it is impossible because I get error REQUEST_WITH_ID_ALREADY_EXIST.
The only solution that worked for me was calling
fetch.delete(id);
or fetch.remove(id);
before each download.
Do you need to store requests in database that succeed or failed? What about removing them just after download succeed or failed?
- How to download from two different urls to same directory? So same scenario like above but we have two different urls. Firstly we fetch from the first one…then delete the file…then download from second url. I get error like REQUEST_WITH_FILE_PATH_ALREADY_EXIST. Unfortunately I don’t have solution for this. The only thing that comes to my mind is to remove all Requests immediately when they completes download (success or error). But why it cannot be done by library?
Thanks in advance for your time 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Remove completed move requests Exchange - ALI TAJRAN
Remove completed move requests with a single command through Exchange Management Shell. How to do it? Learn more in this article.
Read more >Removing a database with old export requests
I'm getting an error saying that I can't remove the database since "This mailbox database is associated with one or more active MailboxExport ......
Read more >Using a delete request to deleting archived data - IBM
You can remove data from the database by a creating and running a separate delete request, or data can be deleted during the...
Read more >How to Remove Yourself from National Database - DeleteMe
DeleteMe's National Database Review Removing yourself from InfoTracer requires you to perform their online opt-out process, and then verify ...
Read more >Part 23 Why deleting database records using get request is bad
In this video we will discuss, why deleting database records using GET request is bad. Please watch Part 22, before proceeding.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@marcin-adamczewski
Question 1. Reason for Fetch’s behavior By default, Fetch stores all request in a database. Unless you provide your own ID for a request, Fetch uses a request’s url + file path to create a unique
ID
. If that unique ID is already found in the Fetch database, Fetch will not enqueue a new request with the same information. Also, Fetch will not enqueue any new request with a File Path that already exist in the database for another request. The reason for this is because we do not want two request that are downloading with the same file path try to save data in that one file. This would cause data corruption. In the case of a user deleting the file outside your app, Fetch will still maintain a record of the request for that downloaded file. You must remove the existing request first before enqueuing it again.Solution 1: Remove exiting request and enqueue again
Solution 2: If you do not want Fetch to permanently store request data to a database on the local storage disk, you can create a temporary in memory database. Fetch will not persist any data from an in memory temporary database when the app is closed. Get a new Instance of Fetch like the following:
Solution 3: You can simply delete a request from Fetch when a download completes or fails.
Question 2 The information I provided in question 1 about Fetch’s behaviors answers this question in part. The reason why Fetch was designed with a database is to help resume incomplete downloads and to also provide you with request information when needed. You should delete request information from Fetch when no longer needed.
What I can do is to add a new option on the Fetch Builder that you can enable to auto delete records from the Fetch database when a download completes or fails after Fetch has reported this information to the Fetch Listeners.
Let me know if this helps or if you have more questions
@tonyofrancis Wow, you’re fast 😃 I like the customisations you introduced. I’ll test it tomorrow 😃 Nevertheless I think that if you want to not make options like AUTO_REMOVE_ON_COMPLETED and AUTO_REMOVE_ON_FAILED default, then such behaviour should be mentioned in Wiki so people are not confused and won’t get into trouble.
Thanks 👍