Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit aa49066

Browse files
committed
Merge pull request #43 from couchbaselabs/feature/issue_954_putLocalDocument
Fixed Java Core 954 - Conflict during putLocalDocument
2 parents ea8f5cc + 62c1d87 commit aa49066

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/com/couchbase/lite/store/ForestDBStore.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ private static Map<String,Object> getDocProperties(byte[] body){
12661266
* revisionID: (NSString*)revID
12671267
* obeyMVCC: (BOOL)obeyMVCC;
12681268
*/
1269-
private Status deleteLocalDocument(final String inDocID, String inRevID, boolean obeyMVCC) {
1269+
private Status deleteLocalDocument(final String inDocID, String inRevID, final boolean obeyMVCC) {
12701270
final String docID = inDocID;
12711271
final String revID = inRevID;
12721272

@@ -1285,15 +1285,18 @@ public Status run() {
12851285
byte[][] metaNbody = forest.rawGet("_local", docID);
12861286
if (metaNbody == null) {
12871287
return new Status(Status.NOT_FOUND);
1288-
} else if (!revID.equals(new String(metaNbody[0]))) {
1288+
} else if (obeyMVCC && revID != null && !revID.equals(new String(metaNbody[0]))) {
12891289
return new Status(Status.CONFLICT);
12901290
} else {
12911291
forest.rawPut("_local", docID, null, null);
12921292
return new Status(Status.OK);
12931293
}
12941294
} catch (ForestException e) {
12951295
Log.e(TAG, "Error in deleteLocalDocument()", e);
1296-
return new Status(Status.UNKNOWN);
1296+
if (e.domain == C4ErrorDomain.ForestDBDomain && e.code == FDBErrors.FDB_RESULT_KEY_NOT_FOUND)
1297+
return new Status(Status.NOT_FOUND);
1298+
else
1299+
return new Status(Status.UNKNOWN);
12971300
}
12981301
}
12991302
});

0 commit comments

Comments
 (0)