From e4d708950663f643703f250140434d595fb2f2d8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 8 Mar 2021 09:53:32 -0500 Subject: [PATCH] Mendeley import: Fix blank PDF attachment MIME type from previous imports --- .../content/zotero/import/mendeley/mendeleyImport.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/import/mendeley/mendeleyImport.js b/chrome/content/zotero/import/mendeley/mendeleyImport.js index 1efb1b9bfc..bf9d5e6f17 100644 --- a/chrome/content/zotero/import/mendeley/mendeleyImport.js +++ b/chrome/content/zotero/import/mendeley/mendeleyImport.js @@ -1091,7 +1091,7 @@ Zotero_Import_Mendeley.prototype._saveFilesAndAnnotations = async function (file // this file annotations.filter(a => a.hash == file.hash), parentItemID, - (attachment && file.contentType == 'application/pdf') ? attachment.id : null, + attachment ? attachment.id : null, file.hash ); } @@ -1165,6 +1165,15 @@ Zotero_Import_Mendeley.prototype._saveAnnotations = async function (annotations, if (attachmentItem) { let file = await attachmentItem.getFilePathAsync(); if (file) { + // Fix blank PDF attachment MIME type from previous imports + if (!attachmentItem.attachmentContentType) { + let type = 'application/pdf'; + if (Zotero.MIME.sniffForMIMEType(await Zotero.File.getSample(file)) == type) { + attachmentItem.attachmentContentType = type; + await attachmentItem.saveTx(); + } + } + let annotationMap = new Map(); for (let annotation of annotations) { // 'type', 'uuid', 'hash', 'color', 'dateAdded', 'page'