Remove the DownloadManager.onerror
functionality, since its only usage is unlikely to be helpful
Note how the `onerror` functionality is not being used in the GENERIC `DownloadManager`, since we have no way of knowing if downloading succeeded. Hence this functionality is only *possibly* useful in MOZCENTRAL builds, however as outlined in the existing comments it's unlikely to be helpful in practice. Generally speaking, if downloading failed once in [`PdfStreamConverter.jsm`](https://searchfox.org/mozilla-central/rev/809ac3660845fef6faf18ec210232fdadc0f1ad9/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#294-406) it seems very likely that it would fail again; all-in-all I'm thus suggesting that we just remove the `onerror` functionality altogether here.
This commit is contained in:
parent
c4b95d925f
commit
775d45b36a
10
web/app.js
10
web/app.js
@ -993,11 +993,6 @@ const PDFViewerApplication = {
|
|||||||
const downloadManager = this.downloadManager,
|
const downloadManager = this.downloadManager,
|
||||||
url = this.baseUrl,
|
url = this.baseUrl,
|
||||||
filename = this._docFilename;
|
filename = this._docFilename;
|
||||||
downloadManager.onerror = err => {
|
|
||||||
// This error won't really be helpful because it's likely the
|
|
||||||
// fallback won't work either (or is already open).
|
|
||||||
this.error(`PDF failed to download: ${err}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
// When the PDF document isn't ready, or the PDF file is still downloading,
|
// When the PDF document isn't ready, or the PDF file is still downloading,
|
||||||
// simply download using the URL.
|
// simply download using the URL.
|
||||||
@ -1023,11 +1018,6 @@ const PDFViewerApplication = {
|
|||||||
const downloadManager = this.downloadManager,
|
const downloadManager = this.downloadManager,
|
||||||
url = this.baseUrl,
|
url = this.baseUrl,
|
||||||
filename = this._docFilename;
|
filename = this._docFilename;
|
||||||
downloadManager.onerror = err => {
|
|
||||||
// This error won't really be helpful because it's likely the
|
|
||||||
// fallback won't work either (or is already open).
|
|
||||||
this.error(`PDF failed to be saved: ${err}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
// When the PDF document isn't ready, or the PDF file is still downloading,
|
// When the PDF document isn't ready, or the PDF file is still downloading,
|
||||||
// simply download using the URL.
|
// simply download using the URL.
|
||||||
|
@ -71,7 +71,6 @@ class DownloadManager {
|
|||||||
this.downloadUrl(url, filename);
|
this.downloadUrl(url, filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
download(blobUrl, filename);
|
download(blobUrl, filename);
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,10 @@ class DownloadManager {
|
|||||||
filename,
|
filename,
|
||||||
sourceEventType,
|
sourceEventType,
|
||||||
}).then(error => {
|
}).then(error => {
|
||||||
if (error && this.onerror) {
|
if (error) {
|
||||||
this.onerror(error);
|
// If downloading failed in `PdfStreamConverter.jsm` it's very unlikely
|
||||||
|
// that attempting to fallback and re-download would be helpful here.
|
||||||
|
console.error("`ChromeActions.download` failed.");
|
||||||
}
|
}
|
||||||
URL.revokeObjectURL(blobUrl);
|
URL.revokeObjectURL(blobUrl);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user