diff options
author | Damien F. Katz <damien@apache.org> | 2009-07-29 21:48:53 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-07-29 21:48:53 +0000 |
commit | a05287f49dc20ef83f89668f1d2603174823565e (patch) | |
tree | d1f3fe2dfeea71a8eb26666c9bb56a2b690c4cde | |
parent | be2828a00e2eba6be47df5648f4e589a43113dbe (diff) |
Fix for COUCHDB-434. Only reassign previous revid inside the updater process.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@799093 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | share/www/script/test/attachments.js | 13 | ||||
-rw-r--r-- | src/couchdb/couch_db.erl | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js index ce7a5d05..4b6fa58e 100644 --- a/share/www/script/test/attachments.js +++ b/share/www/script/test/attachments.js @@ -170,7 +170,18 @@ couchTests.attachments= function(debug) { docs.push(doc) } - db.bulkSave(docs); + var saved = db.bulkSave(docs); + // now delete the docs, and while we are looping over them, remove the + // '_rev' field so we can re-create after deletion. + var to_up = []; + for (i=0;i<saved.length;i++) { + to_up.push({'_id': saved[i]['id'], '_rev': saved[i]['rev'], '_deleted': true}); + delete docs[i]._rev; + } + // delete them. + var saved2 = db.bulkSave(to_up); + // re-create them + var saved3 = db.bulkSave(docs); var before = db.info().disk_size; diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 4e64846c..aff5b743 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -316,13 +316,7 @@ prep_and_validate_update(Db, #doc{id=Id,revs={RevStart, Revs}}=Doc, [] -> % new doc, and we have existing revs. % reuse existing deleted doc - if OldFullDocInfo#full_doc_info.deleted -> - % existing docs are deletions - #doc_info{revs=[#rev_info{rev={Pos, DelRevId}}|_]} = - couch_doc:to_doc_info(OldFullDocInfo), - Doc2 = Doc#doc{revs={Pos, [DelRevId]}}, - {validate_doc_update(Db, Doc2, fun() -> nil end), Doc2}; - AllowConflict -> + if OldFullDocInfo#full_doc_info.deleted orelse AllowConflict -> {validate_doc_update(Db, Doc, fun() -> nil end), Doc}; true -> {conflict, Doc} |