diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 0c916b7dcc..382e819c36 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 6a15042940..abf48d65c4 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 cbf450e9a7..bdd6b74eb8 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();