Webextension: Retry failed download

Is there a way using webextension api to retry a failed download (for reasons like loss of network connectivity)? I looked through history and downloads but couldn’t find a way.

I mean, I can get a list of DownloadItems with downloads.search()but was unable to find a way to restart.

downloads.downloads() only seems to start a fresh download and downloads.resume()doesn’t seem to work for a failed download.

That would seem like there is not then. I hadn’t followed the conversation in the add-ons chat room very closely, but you may want to file a bug to add resuming as an API feature: https://bugzilla.mozilla.org/enter_bug.cgi?product=WebExtensions

Someone has already requested the feature it seems. https://bugzilla.mozilla.org/show_bug.cgi?id=1467059

Not sure what became of it though.

Yet some chrome extensions seem to provide this feature. Like https://chrome.google.com/webstore/detail/auto-resume-downloads/cklhieaaomjcmlaeopmeidpfdjjogjaf.

And I heard people saying ‘down them all’ has it as well.

Ah yes, the ones that can read documentation always win:

1 Like

But does downloads.resume() work for failed downloads? I tried it when a download had failed due to network failure (downloads.InterruptReason) but it wouldn’t work.

Maybe downloads.resume() will work only if the download is paused and not failed? Like with the pause button or downloads.pause().

It is exactly the API the extension you linked above uses. Maybe the bug then is that it doesn’t resume failed downloads in Firefox.

Okay. Thanks for helping out!

Also not all downloads can be resumed. Server needs to support this as well. I don’t know how it’s called though.

Well, if a download fails and the server doesn’t support resuming from offsets/a certain chunk, retrying would just restart the download, which is the expectation here.