commit 36a876021d69e6ca0927f5c6aba51e7a3ad4e73c
parent a91bffd25a39b6f6bfb01e071cb599e5da76932b
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 8 Oct 2009 19:28:59 +0000
- 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
Diffstat:
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git 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
@@ -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
@@ -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();