couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Klaus Trainer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COUCHDB-902) Attachments that have recovered from conflict do not accept attachments.
Date Sun, 09 Jan 2011 23:40:45 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979431#action_12979431
] 

Klaus Trainer commented on COUCHDB-902:
---------------------------------------

I just found the reason for the incorrect responses with status code 201 described in my previous
comment.

The problem is that responses that indicate conflicts are ignored, as the key in the dict:find/2
function call would never match.

The following patch fixes that.


diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 20379ca..0abf347 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -726,9 +726,16 @@ update_docs(Db, Docs, Options, interactive_edit) ->
         
         ResultsDict = dict:from_list(IdRevs ++ CommitResults ++ PreCommitFailures),
         {ok, lists:map(
-            fun(#doc{id=Id,revs={Pos, RevIds}}) ->
-                {ok, Result} = dict:find({Id, {Pos, RevIds}}, ResultsDict),
-                Result
+            fun(#doc{id=Id,revs={0, []}}) ->
+                [];
+            (#doc{id=Id,revs={Pos, RevIds}}) ->
+                case lists:keyfind({Id, {Pos, [hd(RevIds)]}}, 1, CommitResults) of
+                false ->
+                    {ok, Result} = dict:find({Id, {Pos, RevIds}}, ResultsDict),
+                    Result;
+                Result ->
+                    Result
+                end
             end, Docs)}
     end.


I'll attach a revised version of my previously attached patch later.

> Attachments that have recovered from conflict do not accept attachments.
> ------------------------------------------------------------------------
>
>                 Key: COUCHDB-902
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-902
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Database Core
>         Environment: trunk
>            Reporter: Paul Joseph Davis
>            Priority: Critical
>         Attachments: 0001-Fix-COUCHDB-902.patch, couchdb-902-test-case.py
>
>
> Apparently if a document has been in a conflict, they will reject requests to add an
attachment with a conflict error.
> I've tracked this down to couch_db_updater.erl line 501, but I'm not too familiar with
this part of the code so I figured I'd fill out a ticket in case anyone else can go through
this more quickly than me.
> Sure would be nice if I could attach a file when I create an issue...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message