revpos zero problems

14 views
Skip to first unread message

AJ

unread,
Jun 4, 2014, 12:38:41 AM6/4/14
to mobile-c...@googlegroups.com
Oh oh.

I recently had a Cloudant DB migrated from one server to another (see https://groups.google.com/forum/#!topic/mobile-couchbase/ZybaUUPKNmM for some background), and all my attachments now have a revpos value of 0.

CBL considers this an error, which I believe is technically correct.  The first rev of a doc is always 1, so it makes no sense to have a revpos of 0.

Specifically, this little block of code in CBLDatabase+Attachments does the check:

- (NSDictionary*) attachmentsFromRevision: (CBL_Revision*)rev

                                   status: (CBLStatus*)outStatus


...

id revPosObj = attachInfo[@"revpos"];

            if (revPosObj) {

                int revPos = [$castIf(NSNumber, revPosObj) intValue];

                if (revPos <= 0) {

                    *outStatus = kCBLStatusBadAttachment;

                    return nil;

                }

            }


...



So now my iOS 7 App Store app is unable to get any updates.

I can't see any solution other than deleting all attachments (nearly 700!) and re-uploading them all, as this is the only way to reset the revpos.  

I considered changing the code above and doing an app update, but that would mean a probably 7 day wait for approval, and I need to fix this now.

Anyone else out there got any other ideas?

Thx,

- AJ

ps : I'll be contacting Cloudant to see if they can recover the older version of my DB.

Jens Alfke

unread,
Jun 4, 2014, 1:12:56 AM6/4/14
to mobile-c...@googlegroups.com

On Jun 3, 2014, at 9:38 PM, AJ <ad...@great-sky.net> wrote:

CBL considers this an error, which I believe is technically correct.  The first rev of a doc is always 1, so it makes no sense to have a revpos of 0.

Yes, and the revpos is used as an optimization during replication, so if it’s set too low, an attachment might not be replicated even though it’s changed.

I think your only options are what you said — either comment out that check in CBL and resubmit your app, or get Cloudant to fix the revpos on the server. :(

—Jens
Reply all
Reply to author
Forward
0 new messages