Fixes #727, Dragging linked file out of Zotero copies entire parent directory
This commit is contained in:
parent
43c3618a5c
commit
ee92e3603c
|
@ -1490,10 +1490,12 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
var existingFileNames = [];
|
var existingFileNames = [];
|
||||||
|
|
||||||
for (var i=0; i<items.length; i++) {
|
for (var i=0; i<items.length; i++) {
|
||||||
|
// TODO create URL?
|
||||||
if (!items[i].isAttachment() ||
|
if (!items[i].isAttachment() ||
|
||||||
items[i].getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
items[i].getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = items[i].getFile();
|
var file = items[i].getFile();
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Components.utils.reportError("File not found for item " + items[i].getID());
|
Components.utils.reportError("File not found for item " + items[i].getID());
|
||||||
|
@ -1502,14 +1504,16 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
|
|
||||||
// Determine if we need to copy multiple files for this item
|
// Determine if we need to copy multiple files for this item
|
||||||
// (web page snapshots)
|
// (web page snapshots)
|
||||||
var parentDir = file.parent;
|
if (items[i].getAttachmentLinkMode() != Zotero.Attachments.LINK_MODE_LINKED_FILE) {
|
||||||
var files = parentDir.directoryEntries;
|
var parentDir = file.parent;
|
||||||
var numFiles = 0;
|
var files = parentDir.directoryEntries;
|
||||||
while (files.hasMoreElements()) {
|
var numFiles = 0;
|
||||||
var f = files.getNext();
|
while (files.hasMoreElements()) {
|
||||||
f.QueryInterface(Components.interfaces.nsILocalFile);
|
var f = files.getNext();
|
||||||
if (f.leafName.indexOf('.') != 0) {
|
f.QueryInterface(Components.interfaces.nsILocalFile);
|
||||||
numFiles++;
|
if (f.leafName.indexOf('.') != 0) {
|
||||||
|
numFiles++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1545,7 +1549,6 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.debug(e);
|
|
||||||
if (e.name == 'NS_ERROR_FILE_ALREADY_EXISTS') {
|
if (e.name == 'NS_ERROR_FILE_ALREADY_EXISTS') {
|
||||||
// Keep track of items that already existed
|
// Keep track of items that already existed
|
||||||
existingItems.push(items[i].getID());
|
existingItems.push(items[i].getID());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user