The erase()
function of the downloads
API erases matching DownloadItems
from the browser's download history, without deleting the downloaded files from disk.
To remove the files from disk, you need to use downloads.removeFile()
.
This is an asynchronous function that returns a Promise
.
Note: If you want to remove a downloaded file from disk and erase it from history, you have to call downloads.removeFile()
before you call erase()
. If you try it the other way around you'll get an error when calling downloads.removeFile()
, because it no longer exists according to the browser.