Unable to update doc with attachment if attachment was added in the second revision

Hi,

Not sure if it’s already fixed in newest version of CBL for Android, but I noticed in Couchbase Lite version 1.1.0 if I create document and add attachment to it in the second revision, then I can’t update the document w/o providing new attachment. In logcat I see message from CBLite: “No pending attachment for digest …”. Here is the code I used:

Creating doc w/o attachments:

           Document doc = collection.whiteboard.getDocument((String) properties.get("_id"));
           try {
                doc.putProperties(properties);
                if (!addAttachment(doc, attachmentName, fileUri)) {
                    // ...
                }
            } catch (CouchbaseLiteException e) {
                // ...
            }

Adding attachment:

private boolean addAttachment(final Document doc, final String attachmentName, final String fileUri) {
    SavedRevision savedRevision;
    try {
        savedRevision = doc.update(new Document.DocumentUpdater() {
            @Override
            public boolean update(UnsavedRevision newRevision) {
                InputStream inputStream;
                try {
                    inputStream = new FileInputStream(Uri.parse(fileUri).getPath());
                } catch (FileNotFoundException e) {
                    return false;
                }
                newRevision.setAttachment(attachmentName, "image", inputStream);
                return true;
            }
        });
    } catch (CouchbaseLiteException e) {
        return false;
    }
    return savedRevision != null;
}

The next time I update this doc using the following code it fails:

    try {
        doc.update(new Document.DocumentUpdater() {
            @Override
            public boolean update(UnsavedRevision newRevision) {
                newRevision.setUserProperties(properties);
                return true;
            }
        });
    } catch (CouchbaseLiteException e) {
        // ...
    }

Hi Pavel,

It looks like this is a known issue that was solved in 1.2. See https://github.com/couchbase/couchbase-lite-java-core/issues/699 and https://github.com/couchbase/couchbase-lite-java-core/issues/693.

Hod