Skip to content

Commit

Permalink
Fixed assertion failure pushing a rev that's already compacted/pruned
Browse files Browse the repository at this point in the history
Fixes #1217
  • Loading branch information
snej committed May 4, 2016
1 parent a0975fc commit 2864e0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Source/CBLRestPusher.m
Expand Up @@ -282,14 +282,19 @@ - (void) uploadChanges: (CBL_RevisionList*)changes
CBLStatus status;
CBL_Revision* loadedRev = [db revisionByLoadingBody: rev
status: &status];
if (loadedRev && !loadedRev.properties)
if (loadedRev && !loadedRev.properties) {
loadedRev = nil;
status = kCBLStatusBadJSON;
if (status >= 300) {
Warn(@"%@: Couldn't get local contents of %@ (status=%d)", self, rev, status);
}
if (!loadedRev) {
if (status != kCBLStatusNotFound)
Warn(@"%@: Couldn't get local contents of %@ (status=%d)",
self, rev, status);
if (status < 500)
[self removePending: rev];
else
[self revisionFailed]; // db error, may be temporary
continue;
}

if ($castIf(NSNumber, loadedRev[@"_removed"]).boolValue) {
Expand Down
2 changes: 0 additions & 2 deletions Source/CBL_SQLiteStorage.m
Expand Up @@ -719,8 +719,6 @@ - (CBL_MutableRevision*) getDocumentWithID: (NSString*)docID


- (CBLStatus) loadRevisionBody: (CBL_MutableRevision*)rev {
if (rev.body && rev.sequenceIfKnown)
return kCBLStatusOK; // no-op
Assert(rev.docID && rev.revID);
SInt64 docNumericID = [self getDocNumericID: rev.docID];
if (docNumericID <= 0)
Expand Down

0 comments on commit 2864e0b

Please sign in to comment.