couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [22/50] git commit: Bubble missing_stub errors
Date Sat, 18 Jan 2014 00:47:47 GMT
Bubble missing_stub errors

If we try and replicate a doc with attachment stubs to a node that
doesn't have a previous revision of that doc then we should return a
missing_stub error instead of dying with a function_clause error.

BugzId: 15562


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/e4f52424
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/e4f52424
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/e4f52424

Branch: refs/heads/import
Commit: e4f52424fc99ab4c6bd0bb09ed8df66b62ff541c
Parents: bd7e7e8
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Nov 13 17:25:35 2012 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Fri Jan 17 16:44:30 2014 -0800

----------------------------------------------------------------------
 src/couch_db.erl | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/e4f52424/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index 67c8a49..f5953a1 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -708,7 +708,13 @@ prep_and_validate_replicated_updates(Db, [Bucket|RestBuckets], [OldInfo|RestOldI
 
                     case couch_doc:has_stubs(Doc) of
                     true ->
-                        DiskDoc = LoadPrevRevFun(),
+                        DiskDoc = case LoadPrevRevFun() of
+                            #doc{} = DiskDoc0 ->
+                                DiskDoc0;
+                            _ ->
+                                % Force a missing_stub exception
+                                couch_doc:merge_stubs(Doc, #doc{})
+                        end,
                         Doc2 = couch_doc:merge_stubs(Doc, DiskDoc),
                         GetDiskDocFun = fun() -> DiskDoc end;
                     false ->


Mime
View raw message