|
[PATCH] _bulk_docs: Make deleting a deleted document a conflict: msg#00075db.couchdb.devel
When using the REST API, if one tries to delete a document which has already been deleted, he receives a 404 error. However, if one tries the same thing with the _bulk_docs API, the deletion is accepted without error. This patch causes _bulk_docs to generate a 412 error if one attempts to delete a document which has already been deleted. Signed-off-by: Michael Hendricks <michael-u4WEhoUc4zfYtjvyW6yDsg@xxxxxxxxxxxxxxxx> --- share/www/script/couch_tests.js | 10 ++++++++++ src/couchdb/couch_db.erl | 4 +++- 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 6a1e72c..7c8af78 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -223,6 +223,16 @@ var tests = { T(result.new_revs.length == 5); for (i = 0; i < 5; i++) { T(db.open(docs[i]._id) == null); + docs[i]._deleted = true; + } + + // Deleting the docs again fails + try { + db.bulkSave(docs); + T("no double delete conflict" && false); // we shouldn't hit here + } catch (e) { + T(e.error == "conflict"); + T(e.reason == "Update conflict"); } }, diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 05b584a..f8330ed 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -238,6 +238,8 @@ prepare_doc_for_new_edit(Db, #doc{id=Id,revs=[NewRev|PrevRevs]}=Doc, OldFullDocI case PrevRevs of [PrevRev|_] -> case dict:find(PrevRev, LeafRevsDict) of + {ok, {true, Sp, DiskRevs}} -> + throw(conflict); {ok, {Deleted, Sp, DiskRevs}} -> case couch_doc:has_stubs(Doc) of true -> @@ -1035,4 +1037,4 @@ start_copy_compact_int(#db{name=Name,filepath=Filepath}=Db, CopyLocal) -> Db#db.update_pid ! {compact_done, CompactFile}. - \ No newline at end of file + -- 1.5.6 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Hello couchDB world: 00075, Noah Slater |
|---|---|
| Next by Date: | Integrated Full Text Indexing and Reporting Re: CouchDB 0.9 and 1.0: 00075, Damien Katz |
| Previous by Thread: | Hello couchDB worldi: 00075, Philippe Ombredanne |
| Next by Thread: | [jira] Created: (COUCHDB-90) A custom query should not run until the user clicks the "Run" button: 00075, Matt Goodall (JIRA) |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |