|
@@ -62,9 +62,10 @@ singlefile.download = (() => {
|
|
|
return await downloadPage(message, { confirmFilename: message.confirmFilename, incognito: tab.incognito, filenameConflictAction: message.filenameConflictAction });
|
|
return await downloadPage(message, { confirmFilename: message.confirmFilename, incognito: tab.incognito, filenameConflictAction: message.filenameConflictAction });
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(error); // eslint-disable-line no-console
|
|
console.error(error); // eslint-disable-line no-console
|
|
|
- URL.revokeObjectURL(message.url);
|
|
|
|
|
singlefile.ui.onError(sender.tab.id, {});
|
|
singlefile.ui.onError(sender.tab.id, {});
|
|
|
return {};
|
|
return {};
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ URL.revokeObjectURL(message.url);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -100,7 +101,6 @@ singlefile.download = (() => {
|
|
|
} else if (errorMessage == "conflictaction prompt not yet implemented" && options.filenameConflictAction) {
|
|
} else if (errorMessage == "conflictaction prompt not yet implemented" && options.filenameConflictAction) {
|
|
|
return downloadPage(page, { confirmFilename: options.confirmFilename });
|
|
return downloadPage(page, { confirmFilename: options.confirmFilename });
|
|
|
} else if (errorMessage.includes("canceled")) {
|
|
} else if (errorMessage.includes("canceled")) {
|
|
|
- URL.revokeObjectURL(page.url);
|
|
|
|
|
return {};
|
|
return {};
|
|
|
} else {
|
|
} else {
|
|
|
throw error;
|
|
throw error;
|
|
@@ -115,13 +115,11 @@ singlefile.download = (() => {
|
|
|
function onChanged(event) {
|
|
function onChanged(event) {
|
|
|
if (event.id == downloadId && event.state) {
|
|
if (event.id == downloadId && event.state) {
|
|
|
if (event.state.current == "complete") {
|
|
if (event.state.current == "complete") {
|
|
|
- URL.revokeObjectURL(page.url);
|
|
|
|
|
resolve({});
|
|
resolve({});
|
|
|
browser.downloads.onChanged.removeListener(onChanged);
|
|
browser.downloads.onChanged.removeListener(onChanged);
|
|
|
}
|
|
}
|
|
|
if (event.state.current == "interrupted") {
|
|
if (event.state.current == "interrupted") {
|
|
|
if (event.error && event.error.current == "USER_CANCELED") {
|
|
if (event.error && event.error.current == "USER_CANCELED") {
|
|
|
- URL.revokeObjectURL(page.url);
|
|
|
|
|
resolve({});
|
|
resolve({});
|
|
|
} else {
|
|
} else {
|
|
|
reject(new Error(event.state.current));
|
|
reject(new Error(event.state.current));
|