mail-autoexpunge.c revision 94b21eb8dbb74c58348d9e62bb05282383fa09fb
/* Copyright (c) 2015-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "mailbox-list-iter.h"
#include "mail-storage-private.h"
#include "mail-namespace.h"
#include "mail-user.h"
#include "mail-autoexpunge.h"
static int
unsigned int max_mails)
{
struct mailbox_transaction_context *t;
struct mailbox_metadata metadata;
const struct mail_index_header *hdr;
struct mailbox_status status;
int ret = 0;
if ((unsigned int)ioloop_time < interval_time)
expire_time = 0;
else
/* first try to check quickly from mailbox list index if we should
bother opening this mailbox. */
/* autocreated mailbox doesn't exist yet */
return 0;
}
return -1;
}
return 0;
&metadata) < 0)
return -1;
return 0;
}
return -1;
t = mailbox_transaction_begin(box, 0);
/* max_mails is still being reached -> expunge.
don't even check saved-dates before we're
below max_mails. */
} else if (interval_time == 0) {
/* only max_mails is used. nothing further to do. */
break;
if (timestamp > expire_time)
break;
/* already expunged */
} else {
/* failed */
ret = -1;
break;
}
}
if (mailbox_transaction_commit(&t) < 0)
ret = -1;
return ret;
}
static void
unsigned int autoexpunge,
unsigned int autoexpunge_max_mails)
{
/* autoexpunge is configured by admin, so we can safely ignore
any ACLs the user might normally have against expunging in
the mailbox. */
i_error("Failed to autoexpunge mailbox '%s': %s",
}
mailbox_free(&box);
}
static void
const struct mailbox_settings *set)
{
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
} T_END;
if (mailbox_list_iter_deinit(&iter) < 0) {
i_error("Failed to iterate autoexpunge mailboxes '%s%s': %s",
}
}
{
struct mailbox_settings *const *box_set;
const char *vname;
return;
if ((*box_set)->autoexpunge == 0 &&
(*box_set)->autoexpunge_max_mails == 0)
continue;
else {
else
(*box_set)->autoexpunge_max_mails);
}
}
}
{
struct mail_namespace *ns;
}
}