Permalink
Browse files

Decided that the 409s on attachments have to be handled outside of ad…

…dAttachment
  • Loading branch information...
1 parent 86664b3 commit d800405f39874c94eb23bad53aa40dae02ab0edd Martin Murphy committed Oct 22, 2009
Showing with 4 additions and 7 deletions.
  1. BIN lib/couchdb/.database.js.swp
  2. +4 −7 lib/couchdb/database.js
View
BIN lib/couchdb/.database.js.swp
Binary file not shown.
View
11 lib/couchdb/database.js
@@ -271,7 +271,7 @@ Database = {
},
addAttachmentToDoc: function(doc, attachmentName, contentType, attachmentData) {
- var response = true;
+ var status;
if (doc._rev === undefined) {
throw new Error("Argument 'doc' must have a '_rev' property in order to add attachments.");
@@ -281,8 +281,6 @@ Database = {
}
var uri = this.uri + doc._id + "/" + attachmentName + "?rev=" + doc._rev;
- var status = "409";
- while (status == 409){
this.httpClient.put(uri, {
headers: [ { "label" : "Content-Type", "value": contentType }],
@@ -291,19 +289,18 @@ Database = {
async: false,
dataType: "json",
success: function(data, textStatus) {
+ status = textStatus;
if (!data.ok) {
- response = false;
return;
}
doc._rev = data.rev;
},
error: function(xhr) {
- status =xhr.status;
+ status = xhr.status;
}
});
- }
- return response;
+ return status;
},
removeAttachmentFromDoc: function(doc, attachmentName) {
var response = true;

0 comments on commit d800405

Please sign in to comment.