Просмотр исходного кода

revoke URLs later when teh download fails

Gildas 6 лет назад
Родитель
Сommit
5f49bcc447
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      extension/core/bg/download.js

+ 3 - 1
extension/core/bg/download.js

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