From 36a876021d69e6ca0927f5c6aba51e7a3ad4e73c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 8 Oct 2009 19:28:59 +0000 Subject: [PATCH] - Fix error when dragging item with missing child attachment to another library - Fix another cross-library problem (which may or may not have been exposed) that showed up in testing --- chrome/content/zotero/xpcom/attachments.js | 4 ++-- chrome/content/zotero/xpcom/data/relations.js | 9 ++++----- chrome/content/zotero/xpcom/file.js | 3 +++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 0c916b7dc..382e819c3 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -1110,8 +1110,8 @@ Zotero.Attachments = new function(){ } newAttachment.save(); - // Copy over files - if (newAttachment.isImportedAttachment()) { + // Copy over files if they exist + if (newAttachment.isImportedAttachment() && attachment.getFile()) { var dir = Zotero.Attachments.getStorageDirectory(attachment.id); var newDir = Zotero.Attachments.createDirectoryForItem(newAttachment.id); Zotero.File.copyDirectory(dir, newDir); diff --git a/chrome/content/zotero/xpcom/data/relations.js b/chrome/content/zotero/xpcom/data/relations.js index 6a1504294..abf48d65c 100644 --- a/chrome/content/zotero/xpcom/data/relations.js +++ b/chrome/content/zotero/xpcom/data/relations.js @@ -112,15 +112,14 @@ Zotero.Relations = new function () { predicate = _getPrefixAndValue(predicate).join(':'); var relation = new Zotero.Relation; + if (!libraryID) { + libraryID = Zotero.libraryID; + } if (libraryID) { relation.libraryID = parseInt(libraryID); } else { - libraryID = Zotero.libraryID; - if (!libraryID) { - libraryID = Zotero.getLocalUserKey(true); - } - relation.libraryID = parseInt(libraryID); + relation.libraryID = "local/" + Zotero.getLocalUserKey(true); } relation.subject = subject; relation.predicate = predicate; diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index cbf450e9a..bdd6b74eb 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -184,6 +184,9 @@ Zotero.File = new function(){ * Copies all files from dir into newDir */ this.copyDirectory = function (dir, newDir) { + if (!dir.exists()) { + throw ("Directory doesn't exist in Zotero.File.copyDirectory()"); + } var otherFiles = dir.directoryEntries; while (otherFiles.hasMoreElements()) { var file = otherFiles.getNext();