Skip to content

Commit

Permalink
fix: Infinite download in edge when aria2 is disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhua committed Feb 28, 2024
1 parent 97569f2 commit 598be19
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ const isDownloadListened = () => chrome.downloads.onDeterminingFilename.hasListe
/**
* @typedef DownloadItem
* @type {Object}
* @property {string} url - Single url or multiple urls which are conjunct with '\n'
* @property {string} url - Single url or multiple urls which are conjunct with '\n'.
* @property {string} filename
* @property {string} referrer
* @property {Object} options
* @property {boolean} multiTask Indicate whether includes multiple urls
* @property {Object} options - Aria2 RPC options
* @property {boolean} multiTask - Indicate whether includes multiple urls.
* @property {string} type - "DOWNLOAD_VIA_BROWSER" will invoke a chrome download.
*/


Expand Down Expand Up @@ -202,6 +203,10 @@ function shouldCapture(downloadItem) {
var currentTabUrl = new URL(CurrentTabUrl);
var url = new URL(downloadItem.referrer || downloadItem.url);

if (downloadItem.byExtensionId == chrome.runtime.id) {
return false;
}

if (downloadItem.error || downloadItem.state != "in_progress" || !/^(https?|s?ftp):/i.test(downloadItem.url)) {
return false;
}
Expand Down

0 comments on commit 598be19

Please sign in to comment.