<commit_before>/* Copyright (C) 2004 <NAME> */

#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "mmap-util.h"
#include "mail-index-view-private.h"
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
#include "mail-transaction-log-private.h"

static void
mail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
				  struct mail_index_map *map, bool eol)
{
	uint32_t prev_seq;
	uoff_t prev_offset;

	mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
					       &prev_seq, &prev_offset);

	if (!eol) {
		i_assert(prev_seq == map->hdr.log_file_seq);
		i_assert(prev_offset >= map->hdr.log_file_head_offset);

		if (prev_offset == ctx->ext_intro_end_offset &&
		    prev_seq == ctx->ext_intro_seq) {
			/* previous transaction was an extension introduction.
			   we probably came here from
			   mail_index_sync_ext_reset(). if there are any more
			   views which want to continue syncing it needs the
			   intro. so back up a bit more.

			   don't do this in case the last transaction in the
			   log is the extension intro, so we don't keep trying
			   to sync it over and over again. */
			prev_offset = ctx->ext_intro_offset;
		}
	} else {
		i_assert(ctx->view->index->log->head->hdr.file_seq == prev_seq);
		map->hdr.log_file_seq = prev_seq;
	}
	map->hdr.log_file_head_offset = prev_offset;
}

#if 0 // FIXME: can we / do we want to support this?
static int
mail_index_map_msync(struct mail_index *index, struct mail_index_map *map)
{
	if (MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
		buffer_write(map->hdr_copy_buf, 0, &map->hdr, sizeof(map->hdr));
		return 0;
	}
<commit_msg>Removed broken asserts<commit_after>/* Copyright (C) 2004 <NAME> */

#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "mmap-util.h"
#include "mail-index-view-private.h"
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
#include "mail-transaction-log-private.h"

static void
mail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
				  struct mail_index_map *map, bool eol)
{
	uint32_t prev_seq;
	uoff_t prev_offset;

	mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
					       &prev_seq, &prev_offset);

	if (!eol) {
		if (prev_offset == ctx->ext_intro_end_offset &&
		    prev_seq == ctx->ext_intro_seq) {
			/* previous transaction was an extension introduction.
			   we probably came here from
			   mail_index_sync_ext_reset(). if there are any more
			   views which want to continue syncing it needs the
			   intro. so back up a bit more.

			   don't do this in case the last transaction in the
			   log is the extension intro, so we don't keep trying
			   to sync it over and over again. */
			prev_offset = ctx->ext_intro_offset;
		}
	} else {
		i_assert(ctx->view->index->log->head->hdr.file_seq == prev_seq);
		map->hdr.log_file_seq = prev_seq;
	}
	map->hdr.log_file_head_offset = prev_offset;
}

#if 0 // FIXME: can we / do we want to support this?
static int
mail_index_map_msync(struct mail_index *index, struct mail_index_map *map)
{
	if (MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
		buffer_write(map->hdr_copy_buf, 0, &map->hdr, sizeof(map->hdr));
		return 0;
	}

{'fraction_non_alphanumeric': 0.1150581578120088, 'fraction_numerical': 0.005658597925180761, 'mean_word_length': 3.940993788819876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2542463', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1129, 'n_words': 288}