couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1086944 - in /couchdb/trunk: share/www/script/test/attachments.js src/couchdb/couch_httpd_db.erl
Date Wed, 30 Mar 2011 13:15:01 GMT
Author: davisp
Date: Wed Mar 30 13:15:01 2011
New Revision: 1086944

URL: http://svn.apache.org/viewvc?rev=1086944&view=rev
Log:
Invalid _rev's should cause 409 for attachments.

We were masking a conflict error with a server error by not having
a specific clause to catch when a revision doesn't exist. This
adds the clause and a test for the error.

Thanks to Klaus Trainer for the patch.

Closes COUCHDB-1018


Modified:
    couchdb/trunk/share/www/script/test/attachments.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/test/attachments.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/attachments.js?rev=1086944&r1=1086943&r2=1086944&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/attachments.js (original)
+++ couchdb/trunk/share/www/script/test/attachments.js Wed Mar 30 13:15:01 2011
@@ -99,12 +99,21 @@ couchTests.attachments= function(debug) 
   T(xhr.responseText == bin_data);
   TEqualsIgnoreCase("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type"));
 
+  // without rev
   var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt", {
     headers:{"Content-Type":"text/plain;charset=utf-8"},
     body:bin_data
   });
   T(xhr.status == 409);
 
+  // with nonexistent rev
+  var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt"  + "?rev=1-adae8575ecea588919bd08eb020c708e",
{
+    headers:{"Content-Type":"text/plain;charset=utf-8"},
+    body:bin_data
+  });
+  T(xhr.status == 409);
+
+  // with current rev
   var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev, {
     headers:{"Content-Type":"text/plain;charset=utf-8"},
     body:bin_data

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=1086944&r1=1086943&r2=1086944&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Wed Mar 30 13:15:01 2011
@@ -1081,8 +1081,9 @@ db_attachment_req(#httpd{method=Method,m
             #doc{id=DocId};
         Rev ->
             case couch_db:open_doc_revs(Db, DocId, [Rev], []) of
-            {ok, [{ok, Doc0}]}  -> Doc0;
-            {ok, [Error]}       -> throw(Error)
+                {ok, [{ok, Doc0}]} -> Doc0;
+                {ok, [{{not_found, missing}, Rev}]} -> throw(conflict);
+                {ok, [Error]} -> throw(Error)
             end
     end,
 



Mime
View raw message