Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear database and all downloads #10

Closed
mrTimay opened this issue Feb 27, 2017 · 1 comment
Closed

Clear database and all downloads #10

mrTimay opened this issue Feb 27, 2017 · 1 comment

Comments

@mrTimay
Copy link

mrTimay commented Feb 27, 2017

Is there a way to clear the database to allow re-downloads?
Also is there a way to stop and clear all downloads in progress?

@tonyofrancis
Copy link
Owner

@mrTimay The following code allows you to clear all downloads in the database.

List<RequestInfo> requests = fetch.get();
        
for (RequestInfo request : requests) {
    fetch.remove(request.getId());
}

Fetch downloads one request at a time. If you want to delete the current downloading request you can do something like this.

List<RequestInfo> downloadingRequests = fetch.getByStatus(Fetch.STATUS_DOWNLOADING);

for (RequestInfo downloadingRequest : downloadingRequests) { 
    fetch.pause(downloadingRequest.getId());
    //or
    // fetch.remove(downloadingRequest.getId());
}

I may implement a removeAll() method in the next version release. I did not add one because I did not want users of the API using it loosely being that everything gets deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants