From 0ba89211cef58e1f00d4b7f7e7a87462d32ff186 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 14 Jul 2026 13:48:03 -0400 Subject: [PATCH] Fix race between lastRead update and content-type fix on file open viewAttachment() fired the 'open' notification before launchFile() saved a sniffed content type, so AttachmentReadObserver's concurrent lastRead save could reload the item and discard the pending change, leaving the attachment with a blank or incorrect content type. --- chrome/content/zotero/zoteroPane.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 9c49b2b0fc..fbd57b41b4 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -5624,8 +5624,11 @@ var ZoteroPane = new function () { if (fileExists && !redownload) { Zotero.debug("Opening " + path); - Zotero.Notifier.trigger('open', 'file', item.id); await launchFile(path, item); + // Trigger after launchFile(), which may save a content-type fix + // to the item -- 'open' observers save changes to the item + // (e.g., lastRead), which could discard an in-flight change + Zotero.Notifier.trigger('open', 'file', item.id); continue; } @@ -5670,8 +5673,11 @@ var ZoteroPane = new function () { Zotero.Notifier.trigger('redraw', 'item', []); Zotero.debug("Opening " + path); - Zotero.Notifier.trigger('open', 'file', item.id); await launchFile(path, item); + // Trigger after launchFile(), which may save a content-type fix + // to the item -- 'open' observers save changes to the item + // (e.g., lastRead), which could discard an in-flight change + Zotero.Notifier.trigger('open', 'file', item.id); } });