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

#include "lib.h"
#include "ioloop.h"
#include "index-storage.h"

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>

struct index_notify_file {
	struct index_notify_file *next;

	char *path;
	time_t last_stamp;
};

struct index_notify_io {
	struct index_notify_io *next;
	struct io *io;
	int fd;
};

static void check_timeout(void *context)
{
	struct index_mailbox *ibox = context;
	struct index_notify_file *file;
	struct stat st;
	time_t last_check;
	int notify;

	/* check changes only when we can also notify of new mail */
	last_check = I_MAX(ibox->sync_last_check, ibox->notify_last_check);
	if ((unsigned int)(ioloop_time - last_check) <
	    ibox->min_notify_interval)
		return;

	ibox->notify_last_check = ioloop_time;

	notify = ibox->notify_pending;
	for (file = ibox->notify_files; file != NULL; file = file->next) {
		if (stat(file->path, &st) == 0 &&
		    file->last_stamp != st.st_mtime)
			file->last_stamp = st.st_mtime;
	}

	if (notify) {
		ibox->notify_last_sent = ioloop_time;
		ibox->notify_pending = FALSE;
		ibox->notify_callback(&ibox->box, ibox->notify_context);
	}
}

static void notify_callback(void *context)<commit_msg>Timeout/stat() based mailbox change checker didn't actually ever send notifications.<commit_after>/* Copyright (C) 2002 <NAME> */

#include "lib.h"
#include "ioloop.h"
#include "index-storage.h"

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>

struct index_notify_file {
	struct index_notify_file *next;

	char *path;
	time_t last_stamp;
};

struct index_notify_io {
	struct index_notify_io *next;
	struct io *io;
	int fd;
};

static void check_timeout(void *context)
{
	struct index_mailbox *ibox = context;
	struct index_notify_file *file;
	struct stat st;
	time_t last_check;
	int notify;

	/* check changes only when we can also notify of new mail */
	last_check = I_MAX(ibox->sync_last_check, ibox->notify_last_check);
	if ((unsigned int)(ioloop_time - last_check) <
	    ibox->min_notify_interval)
		return;

	ibox->notify_last_check = ioloop_time;

	notify = ibox->notify_pending;
	for (file = ibox->notify_files; file != NULL; file = file->next) {
		if (stat(file->path, &st) == 0 &&
		    file->last_stamp != st.st_mtime) {
			file->last_stamp = st.st_mtime;
			notify = TRUE;
		}
	}

	if (notify) {
		ibox->notify_last_sent = ioloop_time;
		ibox->notify_pending = FALSE;
		ibox->notify_callback(&ibox->box, ibox->notify_context);
	}
}

static void notify_callback(void *context)
{'fraction_non_alphanumeric': 0.13220870929776382, 'fraction_numerical': 0.003923107100823852, 'mean_word_length': 4.51948051948052, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, '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': '2968961', 'n_tokens_mistral': 1009, 'n_tokens_neox': 956, 'n_words': 224}