Ejemplo n.º 1
0
        public int FindMissingRevisions(RevisionList revs)
        {
            var sortedRevs = new RevisionList(revs);

            sortedRevs.SortByDocID();
            var lastDocId    = (string)null;
            var doc          = (C4Document *)null;
            var removedCount = 0;

            try {
                foreach (var rev in sortedRevs)
                {
                    if (rev.GetDocId() != lastDocId)
                    {
                        lastDocId = rev.GetDocId();
                        Native.c4doc_free(doc);
                        doc = Native.c4doc_get(Forest, lastDocId, true, null);
                        if (doc == null)
                        {
                            continue;
                        }
                    }

                    if (Native.c4doc_selectRevision(doc, rev.GetRevId(), false, null))
                    {
                        removedCount++;
                        revs.Remove(rev);
                    }
                }
            } finally {
                Native.c4doc_free(doc);
            }

            return(removedCount);
        }
        public int FindMissingRevisions(RevisionList revs)
        {
            var sortedRevs = new RevisionList(revs);
            sortedRevs.SortByDocID();
            var lastDocId = (string)null;
            var doc = (C4Document*)null;
            var removedCount = 0;
            try {
                foreach (var rev in sortedRevs) {
                    if (rev.GetDocId() != lastDocId) {
                        lastDocId = rev.GetDocId();
                        Native.c4doc_free(doc);
                        doc = Native.c4doc_get(Forest, lastDocId, true, null);
                        if(doc == null) {
                            continue;
                        }
                    }

                    if (Native.c4doc_selectRevision(doc, rev.GetRevId(), false, null)) {
                        removedCount++;
                        revs.Remove(rev);
                    }
                }
            } finally {
                Native.c4doc_free(doc);
            }

            return removedCount;
        }