Use seconds instead of ms for attachmentLastProcessedModificationTime

This commit is contained in:
Dan Stillman 2021-01-22 02:34:50 -05:00
parent 88f886cb30
commit 89d9efdec7
4 changed files with 10 additions and 7 deletions

View file

@ -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;

View file

@ -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;
});

View file

@ -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);
}
}

View file

@ -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(