Revert "When mimeType is not supplied, try to fetch it from server and redo checks for automatic snapshots."
This reverts commit 6dd94f0a3a
.
This commit is contained in:
parent
0850ca94b1
commit
6ba65270ce
3 changed files with 5 additions and 29 deletions
|
@ -30,8 +30,6 @@ Zotero.Attachments = new function(){
|
|||
this.LINK_MODE_LINKED_URL = 3;
|
||||
this.BASE_PATH_PLACEHOLDER = 'attachments:';
|
||||
|
||||
this.SNAPSHOT_MIMETYPES = ["text/html", "application/xhtml+xml"];
|
||||
|
||||
this.importFromFile = importFromFile;
|
||||
this.linkFromFile = linkFromFile;
|
||||
this.importSnapshotFromFile = importSnapshotFromFile;
|
||||
|
@ -576,7 +574,7 @@ Zotero.Attachments = new function(){
|
|||
};
|
||||
}
|
||||
|
||||
if (this.SNAPSHOT_MIMETYPES.indexOf(mimeType) != -1) {
|
||||
if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
|
||||
var sync = true;
|
||||
|
||||
// Load WebPageDump code
|
||||
|
|
|
@ -330,8 +330,6 @@ Zotero.MIME = new function(){
|
|||
var mimeType = xmlhttp.channel.contentType;
|
||||
}
|
||||
|
||||
if(!mimeType) mimeType = 'application/octet-stream'; //unknown item type according to RFC 2046 section 4.5.1
|
||||
|
||||
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||
.createInstance(Components.interfaces.nsIURL);
|
||||
nsIURL.spec = url;
|
||||
|
|
|
@ -336,16 +336,10 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
// Determine whether to save an attachment
|
||||
if(attachment.snapshot !== false) {
|
||||
if(attachment.document
|
||||
|| (attachment.mimeType && Zotero.Attachments.SNAPSHOT_MIMETYPES.indexOf(attachment.mimeType) != -1)) {
|
||||
if(!Zotero.Prefs.get("automaticSnapshots")) {
|
||||
Zotero.debug("Translate: Automatic snapshots are disabled. Skipping.", 4);
|
||||
return;
|
||||
}
|
||||
|| (attachment.mimeType && attachment.mimeType == "text/html")) {
|
||||
if(!Zotero.Prefs.get("automaticSnapshots")) return;
|
||||
} else {
|
||||
if(!Zotero.Prefs.get("downloadAssociatedFiles")) {
|
||||
Zotero.debug("Translate: File attachments are disabled. Skipping.", 4);
|
||||
return;
|
||||
}
|
||||
if(!Zotero.Prefs.get("downloadAssociatedFiles")) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -411,24 +405,10 @@ Zotero.Translate.ItemSaver.prototype = {
|
|||
// Save attachment if snapshot pref enabled or not HTML
|
||||
// (in which case downloadAssociatedFiles applies)
|
||||
} else {
|
||||
if(!attachment.mimeType && attachment.mimeType !== '') { //in case '' indicates unknwon mime type at some point
|
||||
Zotero.debug("Translate: No mimeType specified for a possible snapshot. Trying to determine mimeType.", 4);
|
||||
var me = this;
|
||||
try {
|
||||
Zotero.MIME.getMIMETypeFromURL(attachment.url, function (mimeType, hasNativeHandler) {
|
||||
attachment.mimeType = mimeType;
|
||||
me._saveAttachmentDownload(attachment, parentID, attachmentCallback);
|
||||
}, this._cookieSandbox);
|
||||
} catch(e) {
|
||||
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
|
||||
attachmentCallback(attachment, false, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
|
||||
var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(parentID);
|
||||
try {
|
||||
Zotero.debug('Translate: Importing attachment from URL', 4);
|
||||
Zotero.debug('Importing attachment from URL');
|
||||
attachment.linkMode = "imported_url";
|
||||
Zotero.Attachments.importFromURL(attachment.url, parentID, title,
|
||||
fileBaseName, null, mimeType, this._libraryID, function(status, err) {
|
||||
|
|
Loading…
Reference in a new issue