diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 87edb15069..5a7e4585db 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3233,10 +3233,11 @@ for (let name of ['lastProcessedModificationTime', 'pageIndex']) { } if (parseInt(val) != val || val < 0) { Zotero.debug(val, 2); - throw new Error(`${prop} must be a timestamp in milliseconds`); + throw new Error(`${prop} must be a timestamp in seconds`); } - if (val < 10000000000) { - Zotero.logError("attachmentlastProcesedModificationTime should be a timestamp in milliseconds " + // Change before 2065! + if (val > 3000000000) { + throw new Error(`${prop} should be a timestamp in seconds ` + "-- " + val + " given"); } break; diff --git a/chrome/content/zotero/xpcom/pdfWorker/manager.js b/chrome/content/zotero/xpcom/pdfWorker/manager.js index 8a911c0558..a9e0693427 100644 --- a/chrome/content/zotero/xpcom/pdfWorker/manager.js +++ b/chrome/content/zotero/xpcom/pdfWorker/manager.js @@ -252,7 +252,9 @@ class PDFWorker { reader.toggleImportPrompt(attachment.attachmentHasUnimportedAnnotations); } } - attachment.attachmentLastProcessedModificationTime = await attachment.attachmentModificationTime; + attachment.attachmentLastProcessedModificationTime = Math.floor( + await attachment.attachmentModificationTime / 1000 + ); await attachment.saveTx(); return annotations.length; }); diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 83c192c579..0df7ee5d35 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -811,7 +811,7 @@ class Reader { async triggerAnnotationsImportCheck(itemID) { let item = await Zotero.Items.getAsync(itemID); let mtime = await item.attachmentModificationTime; - if (item.attachmentLastProcessedModificationTime < mtime) { + if (item.attachmentLastProcessedModificationTime < Math.floor(mtime / 1000)) { await Zotero.PDFWorker.import(itemID, false); } } diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js index 49c8e45c7c..26907c18b6 100644 --- a/test/tests/itemTest.js +++ b/test/tests/itemTest.js @@ -1191,7 +1191,7 @@ describe("Zotero.Item", function () { var item = await createDataObject('item'); var attachment = await importFileAttachment('test.pdf', { parentID: item.id }); - var mtime = Date.now(); + var mtime = Math.floor(Date.now() / 1000); attachment.attachmentLastProcessedModificationTime = mtime; await attachment.saveTx(); @@ -1512,7 +1512,7 @@ describe("Zotero.Item", function () { ); assert.lengthOf(annotationIDs, 1); - attachment.attachmentLastProcessedModificationTime = Date.now(); + attachment.attachmentLastProcessedModificationTime = Math.floor(Date.now() / 1000); await attachment.saveTx(); annotationIDs = await Zotero.DB.columnQueryAsync(