- 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
This commit is contained in:
Dan Stillman 2009-10-08 19:28:59 +00:00
parent a91bffd25a
commit 36a876021d
3 changed files with 9 additions and 7 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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();