Open
Bug 1024461
Opened 11 years ago
Updated 3 years ago
[Downloads.jsm] "DownloadSaver" can not be overridden
Categories
(Toolkit :: Downloads API, defect)
Tracking
()
UNCONFIRMED
People
(Reporter: lordkiron, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 (Beta/Release)
Build ID: 20140506152807
Steps to reproduce:
The problem is in the code.
I am creating extension that will "on fly" convert ".FB2" book files into ".ePub" format files when downloading, using my converter (COM).
The idea is to overlay "unknownContentType.xul" to add additional UI in case .FB2 extension file selected, then to have my own personal "DownloadSaver" based on "copy" DownloadSaver, that at the end , when .part file fully finished will convert .part file (that actually .fb2 inside) to .epub file instead of copy.
Actual results:
Basically I have most of the functionality working besides one thing, in DownloadCore.jsm there is following code:
-----------------------------
this.DownloadSaver.fromSerializable = function (aSerializable) {
let serializable = isString(aSerializable) ? { type: aSerializable }
: aSerializable;
let saver;
switch (serializable.type) {
case "copy":
saver = DownloadCopySaver.fromSerializable(serializable);
break;
case "legacy":
saver = DownloadLegacySaver.fromSerializable(serializable);
break;
default:
throw new Error("Unrecoginzed download saver type.");
}
return saver;
};
---------------------------------------
As result I can not use my own DownloadSaver because in "default" case it throws error and stops.
Expected results:
I believe that DownloadSaver should have real "PlugIn" functionality, allowing to use any DownloadSaver based serializable class.
Also DownloadSaver is not documented in MDN.
Comment 1•11 years ago
|
||
Doesn't the Download.jsm offer a facility for plugging an anti-virus?
Reporter | ||
Comment 2•11 years ago
|
||
(In reply to David Rajchenbach Teller [:Yoric] from comment #1)
> Doesn't the Download.jsm offer a facility for plugging an anti-virus?
Not that I am aware of, but I do not think it will work for my type of request anyway.
You see, the file I download is .FB2 file with .FB2 extension etc.
I need to convert it after actual "fetch" finished and copy it under ".ePub" extension , in such way that it
1. appears in Download list as ePub and can be opened from there.
2. Can be canceled/resumed/ go to download link - I mean full functionality, not just saved.
AV prugin is more like "postprocessing" id does not / can not change destination file path/name.
Reporter | ||
Comment 3•11 years ago
|
||
Btw: I override the function in my jsm to get around it:
------------------------------------------------
this.DownloadSaver.fromSerializable = function (aSerializable) {
let serializable = isString(aSerializable) ? { type: aSerializable }
: aSerializable;
let saver;
switch (serializable.type) {
case "copy":
saver = DownloadCopySaver.fromSerializable(serializable);
break;
case "legacy":
saver = DownloadLegacySaver.fromSerializable(serializable);
break;
case "Fb2DownloadCopySaverToEPub":
dump("\nHere !");
saver = Fb2DownloadCopySaverToEPub.fromSerializable(serializable);
break;
default:
throw new Error("Unrecoginzed download saver type.");
}
return saver;
};
------------------------------------------------
but I still think we need a proper way to add DownloadSavers , not use JS "tricks" for it.
Updated•11 years ago
|
Component: Untriaged → Download Manager
Product: Firefox → Toolkit
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•