commit ef257405108a9236b9230c041e99db27e68bd451
parent d02fe6d9ab87f6bb888c8f00ac433da414643222
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 5 Jul 2012 18:12:00 -0400
Use the same rules for creating links and snapshots, regardless of whether attachments can be saved to the current library
Diffstat:
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -309,17 +309,16 @@ Zotero.Translate.ItemSaver.prototype = {
"_saveAttachmentDownload":function(attachment, parentID) {
Zotero.debug("Translate: Adding attachment", 4);
- // determine whether to save attachments at all
- var automaticSnapshots = Zotero.Prefs.get("automaticSnapshots");
- var downloadAssociatedFiles = Zotero.Prefs.get("downloadAssociatedFiles");
-
if(!attachment.url && !attachment.document) {
Zotero.debug("Translate: Not adding attachment: no URL specified", 2);
} else {
- var shouldAttach = ((attachment.document
- || (attachment.mimeType && attachment.mimeType == "text/html")) && automaticSnapshots)
- || downloadAssociatedFiles;
- if(!shouldAttach) return;
+ // Determine whether to save an attachment
+ if(attachment.document
+ || (attachment.mimeType && attachment.mimeType == "text/html")) {
+ if(!Zotero.Prefs.get("automaticSnapshots")) return;
+ } else {
+ if(!Zotero.Prefs.get("downloadAssociatedFiles")) return;
+ }
if(attachment.document && "__wrappedDOMObject" in attachment.document) {
attachment.document = attachment.document.__wrappedDOMObject;
@@ -347,17 +346,14 @@ Zotero.Translate.ItemSaver.prototype = {
} else {
// if snapshot is not explicitly set to false, retrieve snapshot
if(attachment.document) {
- if(automaticSnapshots) {
- try {
- Zotero.Attachments.importFromDocument(attachment.document, parentID, attachment.title);
- } catch(e) {
- Zotero.debug("Translate: Error attaching document", 2);
- }
+ try {
+ Zotero.Attachments.importFromDocument(attachment.document, parentID, attachment.title);
+ } catch(e) {
+ Zotero.debug("Translate: Error attaching document", 2);
}
// Save attachment if snapshot pref enabled or not HTML
// (in which case downloadAssociatedFiles applies)
- } else if(this._saveFiles && (automaticSnapshots || !attachment.mimeType
- || attachment.mimeType != "text/html")) {
+ } else {
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
var title = (attachment.title ? attachment.title : null);