Ticket #901: patch.diff

File patch.diff, 3.1 KB (added by zeppomedio, 8 years ago)

Patch to allow for saving attachments without saving snapshots

  • chrome/content/zotero/xpcom/translate.js

     
    12861286                } 
    12871287                 
    12881288                // handle attachments 
    1289                 if(item.attachments && Zotero.Prefs.get("automaticSnapshots")) { 
     1289                if(item.attachments && (Zotero.Prefs.get("automaticSnapshots") || Zotero.Prefs.get("downloadAssociatedFiles"))) { 
    12901290                        for each(var attachment in item.attachments) { 
    12911291                                if(this.type == "web") { 
    12921292                                        if(!attachment.url && !attachment.document) { 
     
    13221322                                                                        Zotero.debug("Translate: error attaching document"); 
    13231323                                                                } 
    13241324                                                        } else { 
    1325                                                                 var mimeType = null; 
    1326                                                                 var title = null; 
    1327                                                                  
    1328                                                                 if(attachment.mimeType) { 
    1329                                                                         // first, try to extract mime type from mimeType attribute 
    1330                                                                         mimeType = attachment.mimeType; 
    1331                                                                 } else if(attachment.document && attachment.document.contentType) { 
    1332                                                                         // if that fails, use document if possible 
    1333                                                                         mimeType = attachment.document.contentType 
    1334                                                                 } 
    1335                                                                  
    1336                                                                 // same procedure for title as mime type 
    1337                                                                 if(attachment.title) { 
    1338                                                                         title = attachment.title; 
    1339                                                                 } else if(attachment.document && attachment.document.title) { 
    1340                                                                         title = attachment.document.title; 
    1341                                                                 } 
    1342                                                                  
    1343                                                                 if(this.locationIsProxied) { 
    1344                                                                         attachment.url = Zotero.Ingester.ProxyMonitor.properToProxy(attachment.url); 
    1345                                                                 } 
    1346                                                                  
    1347                                                                 var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(myID); 
    1348                                                                 try { 
    1349                                                                         Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName); 
    1350                                                                 } catch(e) { 
    1351                                                                         Zotero.debug("Zotero.Translate: error adding attachment "+attachment.url); 
    1352                                                                 } 
     1325                                                            if(attachment.url != item.url || Zotero.Prefs.get("automaticSnapshots")){ 
     1326                                                                var mimeType = null; 
     1327                                                                var title = null; 
     1328 
     1329                                                                if(attachment.mimeType) { 
     1330                                                                        // first, try to extract mime type from mimeType attribute 
     1331                                                                        mimeType = attachment.mimeType; 
     1332                                                                } else if(attachment.document && attachment.document.contentType) { 
     1333                                                                        // if that fails, use document if possible 
     1334                                                                        mimeType = attachment.document.contentType 
     1335                                                                } 
     1336 
     1337                                                                // same procedure for title as mime type 
     1338                                                                if(attachment.title) { 
     1339                                                                        title = attachment.title; 
     1340                                                                } else if(attachment.document && attachment.document.title) { 
     1341                                                                        title = attachment.document.title; 
     1342                                                                } 
     1343 
     1344                                                                if(this.locationIsProxied) { 
     1345                                                                        attachment.url = Zotero.Ingester.ProxyMonitor.properToProxy(attachment.url); 
     1346                                                                } 
     1347 
     1348                                                                var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(myID); 
     1349                                                                try { 
     1350                                                                        Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName); 
     1351                                                                } catch(e) { 
     1352                                                                        Zotero.debug("Zotero.Translate: error adding attachment "+attachment.url); 
     1353                                                                }    
     1354                                                            } 
    13531355                                                        } 
    13541356                                                } 
    13551357                                        }