Fix dragging attachments to File Explorer

Firefox 140.14 in Zotero 10.0 made the drag transferable's data
principal null for chrome-initiated drags, so the file-promise stream
that File Explorer used couldn't be created and the drop failed with
"Unspecified error". On Windows the promise was just a file:// URL for
the attachment itself, so hand over the file directly instead, and
force a copy so that File Explorer doesn't move it out of storage.

https://forums.zotero.org/discussion/133399/
https://bugzilla.mozilla.org/show_bug.cgi?id=2054665
This commit is contained in:
Dan Stillman 2026-08-25 14:04:09 -04:00
parent e69ee69218
commit 56eb77b704

View file

@ -3275,11 +3275,10 @@ Zotero.Utilities.Internal.onDragItems = function (event, itemIDs, dragImage = ev
event.dataTransfer.mozSetDataAt("application/x-moz-file-promise", dataProvider, i);
}
// Allow dragging to filesystem on Linux and Windows
let uri;
if (!Zotero.isMac) {
// Allow dragging to filesystem on Linux
if (Zotero.isLinux) {
Zotero.debug("Adding text/x-moz-url " + i);
uri = Zotero.File.pathToFileURI(file);
let uri = Zotero.File.pathToFileURI(file);
event.dataTransfer.mozSetDataAt("text/x-moz-url", uri + '\n' + file.leafName, i);
}
@ -3287,11 +3286,8 @@ Zotero.Utilities.Internal.onDragItems = function (event, itemIDs, dragImage = ev
Zotero.debug("Adding application/x-moz-file " + i);
event.dataTransfer.mozSetDataAt("application/x-moz-file", file, i);
if (Zotero.isWin) {
event.dataTransfer.mozSetDataAt("application/x-moz-file-promise-url", uri, i);
}
else if (Zotero.isLinux) {
// Don't create a symlink for an unmodified drag
if (Zotero.isWin || Zotero.isLinux) {
// Copy rather than move (Windows) or symlink (Linux) for an unmodified drag
event.dataTransfer.effectAllowed = 'copy';
}
}