From commits-return-6099-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Wed Mar 30 13:15:25 2011 Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 16647 invoked from network); 30 Mar 2011 13:15:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Mar 2011 13:15:25 -0000 Received: (qmail 34877 invoked by uid 500); 30 Mar 2011 13:15:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 34832 invoked by uid 500); 30 Mar 2011 13:15:24 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 34825 invoked by uid 99); 30 Mar 2011 13:15:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Mar 2011 13:15:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Mar 2011 13:15:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8BB192388A19; Wed, 30 Mar 2011 13:15:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@couchdb.apache.org From: davisp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110330131501.8BB192388A19@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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,