Fix race between lastRead update and content-type fix on file open
Some checks are pending
CI / Test (shard 1) (push) Waiting to run
CI / Test (shard 2) (push) Waiting to run
CI / Test (shard 3) (push) Waiting to run
CI / Test (shard 4) (push) Waiting to run
CI / Utilities Tests (push) Waiting to run
CI / Build, Upload (push) Waiting to run

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.
This commit is contained in:
Dan Stillman 2026-07-14 13:48:03 -04:00
parent bdea584a17
commit 0ba89211ce

View file

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