diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2010-11-24 16:11:39 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2010-11-24 16:11:39 +0000 |
commit | a61f2eb606d20aa4f790fe927cf31c5f96754527 (patch) | |
tree | 9779b9201b790172649a14e3cbf83d553cc08641 /src | |
parent | 894d8f2cc9c8ebaf6ff025de393b3d95be4bd548 (diff) |
Merged revision 1038665 from trunk:
Replicator DB: added _replication_state_time (a unix timestamp value) to replication documents.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1038666 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_doc.erl | 3 | ||||
-rw-r--r-- | src/couchdb/couch_rep.erl | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl index b014de2d..7c64b8a9 100644 --- a/src/couchdb/couch_doc.erl +++ b/src/couchdb/couch_doc.erl @@ -256,6 +256,9 @@ transfer_fields([{<<"_deleted_conflicts">>, _} | Rest], Doc) -> transfer_fields([{<<"_replication_state">>, _} = Field | Rest], #doc{body=Fields} = Doc) -> transfer_fields(Rest, Doc#doc{body=[Field|Fields]}); +transfer_fields([{<<"_replication_state_time">>, _} = Field | Rest], + #doc{body=Fields} = Doc) -> + transfer_fields(Rest, Doc#doc{body=[Field|Fields]}); transfer_fields([{<<"_replication_id">>, _} = Field | Rest], #doc{body=Fields} = Doc) -> transfer_fields(Rest, Doc#doc{body=[Field|Fields]}); diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl index 663fd838..1b998666 100644 --- a/src/couchdb/couch_rep.erl +++ b/src/couchdb/couch_rep.erl @@ -854,8 +854,15 @@ update_rep_doc({Props} = _RepDoc, KVs) -> update_rep_doc(RepDb, #doc{body = {RepDocBody}} = RepDoc, KVs) -> NewRepDocBody = lists:foldl( - fun({K, _V} = KV, Body) -> - lists:keystore(K, 1, Body, KV) + fun({<<"_replication_state">> = K, _V} = KV, Body) -> + Body1 = lists:keystore(K, 1, Body, KV), + {Mega, Secs, _} = erlang:now(), + UnixTime = Mega * 1000000 + Secs, + lists:keystore( + <<"_replication_state_time">>, 1, + Body1, {<<"_replication_state_time">>, UnixTime}); + ({K, _V} = KV, Body) -> + lists:keystore(K, 1, Body, KV) end, RepDocBody, KVs |