From c05f8a0c48732dff2811ec7b894105e2e731aa03 Mon Sep 17 00:00:00 2001 From: Abe Jellinek <1770299+AbeJellinek@users.noreply.github.com> Date: Tue, 12 May 2026 10:20:27 -0400 Subject: [PATCH] Return up-to-date storage properties, too --- chrome/content/zotero/xpcom/data/item.js | 37 ++++++++++--------- .../zotero/xpcom/server/server_localAPI.js | 1 + 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 206de1b4b4..bdf65b2928 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -5773,24 +5773,21 @@ Zotero.Item.prototype.toJSON = function (options = {}) { } if (this.isStoredFileAttachment() && !options.skipStorageProperties) { - if (options.syncedStorageProperties) { - let mtime = this.attachmentSyncedModificationTime; - // There's never a reason to include these if they're null. This can happen if - // we're restoring to server from a copy of the database that was never - // file-synced. We don't want to clear the remote file associations when that - // happens. - if (mtime !== null) { - obj.mtime = mtime; - } - let md5 = this.attachmentSyncedHash; - if (md5 !== null) { - obj.md5 = md5; - } + // Add synced storage properties even if syncedStorageProperties is false, + // since we can't get the local properties synchronously + // We'll overwrite them in toResponseJSONAsync() if possible + + let mtime = this.attachmentSyncedModificationTime; + // There's never a reason to include these if they're null. This can happen if + // we're restoring to server from a copy of the database that was never + // file-synced. We don't want to clear the remote file associations when that + // happens. + if (mtime !== null) { + obj.mtime = mtime; } - else { - // TEMP - //obj.mtime = (yield this.attachmentModificationTime) || null; - //obj.md5 = (yield this.attachmentHash) || null; + let md5 = this.attachmentSyncedHash; + if (md5 !== null) { + obj.md5 = md5; } } } @@ -5935,6 +5932,12 @@ Zotero.Item.prototype.toResponseJSONAsync = async function (options = {}) { else if (this.isImportedAttachment()) { json.links.enclosure.length = await getFileSize(this); } + + if (this.isStoredFileAttachment() && !options.skipStorageProperties) { + json.data.mtime = await this.attachmentModificationTime ?? null; + json.data.md5 = await this.attachmentHash ?? null; + } + return json; }; diff --git a/chrome/content/zotero/xpcom/server/server_localAPI.js b/chrome/content/zotero/xpcom/server/server_localAPI.js index 3ad1c21b54..35935422ab 100644 --- a/chrome/content/zotero/xpcom/server/server_localAPI.js +++ b/chrome/content/zotero/xpcom/server/server_localAPI.js @@ -901,6 +901,7 @@ async function toResponseJSON(dataObjectOrObjects, searchParams) { ? await dataObject.toResponseJSONAsync({ apiURL: `http://localhost:${Zotero.Server.port}/api/`, includeGroupDetails: true, + syncedStorageProperties: false, syncedVersionProperty: false, }) : dataObject;