Permalink
Browse files

Merge pull request #62 from pegli/repl_change_observer

TDReplicator never calls notifyObservers()
  • Loading branch information...
2 parents ca8e736 + 58ab949 commit 12754b82efba389cf853c9ab800d8028b80cd78c @mschoch mschoch committed Aug 3, 2012
@@ -125,7 +125,7 @@ public void changeTrackerReceivedChange(Map<String, Object> change) {
rev.setSequence(++nextFakeSequence);
addToInbox(rev);
}
- changesTotal+= changes.size();
+ setChangesTotal(getChangesTotal() + changes.size());
}
@Override
@@ -158,7 +158,7 @@ public void processInbox(TDRevisionList inbox) {
// Ask the local database which of the revs are not known to it:
//Log.w(TDDatabase.TAG, String.format("%s: Looking up %s", this, inbox));
String lastInboxSequence = ((TDPulledRevision)inbox.get(inbox.size()-1)).getRemoteSequenceID();
- int total = changesTotal - inbox.size();
+ int total = getChangesTotal() - inbox.size();
if(!db.findMissingRevisions(inbox)) {
Log.w(TDDatabase.TAG, String.format("%s failed to look up local revs", this));
inbox = null;
@@ -168,8 +168,8 @@ public void processInbox(TDRevisionList inbox) {
if(inbox != null) {
inboxCount = inbox.size();
}
- if(changesTotal != total + inboxCount) {
- changesTotal = total + inboxCount;
+ if(getChangesTotal() != total + inboxCount) {
+ setChangesTotal(total + inboxCount);
}
if(inboxCount == 0) {
@@ -260,13 +260,13 @@ public void onCompletion(Object result, Throwable e) {
asyncTaskStarted();
} else {
Log.w(TDDatabase.TAG, this + ": Missing revision history in response from " + pathInside);
- changesProcessed++;
+ setChangesProcessed(getChangesProcessed() + 1);
}
} else {
if(e != null) {
error = e;
}
- changesProcessed++;
+ setChangesProcessed(getChangesProcessed() + 1);
}
// Note that we've finished this task; then start another one if there
@@ -343,7 +343,7 @@ public int compare(List<Object> list1, List<Object> list2) {
asyncTaskFinished(revs.size());
}
- changesProcessed += revs.size();
+ setChangesProcessed(getChangesProcessed() + revs.size());
}
List<String> knownCurrentRevIDs(TDRevision rev) {
@@ -209,7 +209,7 @@ public void onCompletion(Object response, Throwable e) {
bulkDocsBody.put("new_edits", false);
Log.i(TDDatabase.TAG, String.format("%s: Sending %d revisions", this, numDocsToSend));
Log.v(TDDatabase.TAG, String.format("%s: Sending %s", this, inbox));
- changesTotal += numDocsToSend;
+ setChangesTotal(getChangesTotal() + numDocsToSend);
asyncTaskStarted();
sendAsyncRequest("POST", "/_bulk_docs", bulkDocsBody, new TDRemoteRequestCompletionBlock() {
@@ -221,7 +221,7 @@ public void onCompletion(Object result, Throwable e) {
Log.v(TDDatabase.TAG, String.format("%s: Sent %s", this, inbox));
setLastSequence(String.format("%d", lastInboxSequence));
}
- changesProcessed += numDocsToSend;
+ setChangesProcessed(getChangesProcessed() + numDocsToSend);
asyncTaskFinished(1);
}
});
@@ -43,8 +43,8 @@
protected String sessionID;
protected TDBatcher<TDRevision> batcher;
protected int asyncTaskCount;
- protected int changesProcessed;
- protected int changesTotal;
+ private int changesProcessed;
+ private int changesTotal;
protected final HttpClientFactory clientFacotry;
protected String filterName;
protected Map<String,Object> filterParams;

0 comments on commit 12754b8

Please sign in to comment.