Skip to content

Commit a3284fa

Browse files
committed
Handle task with error in callback instead of after await
1 parent 599e7e6 commit a3284fa

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

USERGUIDE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ We're looking into adding such capabilities to Image Downloader in the future. I
2222

2323
📝 Change Log
2424
━━━━━━━
25-
3.3.1:
25+
3.3.2:
2626
- Disable slider handles when the checkbox is unchecked
2727
- Add tooltips to slider handles, slider checkboxes, and the Download button
2828
- Fix some issues with downloads not being cleaned up

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Image Downloader",
33
"description": "Browse and download images on the web",
4-
"version": "3.3.1",
4+
"version": "3.3.2",
55
"minimum_chrome_version": "72",
66
"manifest_version": 2,
77
"icons": {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "image-downloader",
4-
"version": "3.3.1",
4+
"version": "3.3.2",
55
"license": "MIT",
66
"scripts": {
77
"start": "npm run build && node scripts/watch.js",

src/background/downloadImages.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ async function downloadImages(/** @type {Task} */ task) {
3636
tasks.add(task);
3737
for (const image of task.imagesToDownload) {
3838
await new Promise((resolve) => {
39-
chrome.downloads.download({ url: image }, resolve);
39+
chrome.downloads.download({ url: image }, (downloadId) => {
40+
if (downloadId == null) {
41+
if (chrome.runtime.lastError) {
42+
console.error(`${image}:`, chrome.runtime.lastError.message);
43+
}
44+
task.next();
45+
}
46+
resolve();
47+
});
4048
});
41-
if (chrome.runtime.lastError) {
42-
console.error(`${chrome.runtime.lastError.message}: ${image}`);
43-
}
44-
task.next();
4549
}
4650
}
4751

@@ -72,6 +76,7 @@ function suggestNewFilename(item, suggest) {
7276
}
7377

7478
suggest({ filename: normalizeSlashes(newFilename) });
79+
task.next();
7580
}
7681

7782
function normalizeSlashes(filename) {

0 commit comments

Comments
 (0)