Skip importing annotations for non-PDF attachments

This commit is contained in:
Tom Najdek 2024-04-03 13:21:52 +02:00
parent ad661e9c8d
commit 124b64f3a2
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77

View file

@ -1626,13 +1626,19 @@ Zotero_Import_Mendeley.prototype._saveAnnotations = async function (annotations,
let file = await attachmentItem.getFilePathAsync(); let file = await attachmentItem.getFilePathAsync();
if (file) { if (file) {
// Fix blank PDF attachment MIME type from previous imports // Fix blank PDF attachment MIME type from previous imports
let type = 'application/pdf';
if (!attachmentItem.attachmentContentType) { if (!attachmentItem.attachmentContentType) {
let type = 'application/pdf';
if (Zotero.MIME.sniffForMIMEType(await Zotero.File.getSample(file)) == type) { if (Zotero.MIME.sniffForMIMEType(await Zotero.File.getSample(file)) == type) {
attachmentItem.attachmentContentType = type; attachmentItem.attachmentContentType = type;
await attachmentItem.saveTx(this._saveOptions); await attachmentItem.saveTx(this._saveOptions);
} }
} }
if (attachmentItem.attachmentContentType !== type) {
Zotero.debug(`Skipping ${annotations.length} annotations for non-PDF (${attachmentItem.attachmentContentType}) file ${file}`);
// do not attempt to import annotations for non-PDF files
return;
}
let annotationMap = new Map(); let annotationMap = new Map();
for (let annotation of annotations) { for (let annotation of annotations) {