quota-count.c revision bb1c6e2b0337990c8125e214534fcdf8165646e7
/* Copyright (c) 2006-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mailbox-list-iter.h"
#include "quota-private.h"
struct quota_mailbox_iter {
struct quota_root *root;
struct mail_namespace *ns;
unsigned int ns_idx;
struct mailbox_list_iterate_context *iter;
struct mailbox_info info;
bool failed;
};
extern struct quota_backend quota_backend_count;
static int
{
struct quota_rule *rule;
struct mailbox_metadata metadata;
struct mailbox_status status;
enum mail_error error;
const char *errstr;
int ret;
/* mailbox not included in quota */
return 0;
}
ret = 0;
&metadata) < 0 ||
if (error == MAIL_ERROR_TEMP) {
i_error("quota: Couldn't get size of mailbox %s: %s",
ret = -1;
} else {
/* non-temporary error, e.g. ACLs denied access. */
ret = 0;
}
} else {
ret = 1;
}
mailbox_free(&box);
return ret;
}
static struct quota_mailbox_iter *
{
struct quota_mailbox_iter *iter;
return iter;
}
static int
{
i_error("quota: Listing namespace '%s' failed: %s",
ret = -1;
}
}
return ret;
}
static const struct mailbox_info *
{
struct mail_namespace *const *namespaces;
const struct mailbox_info *info;
unsigned int count;
return NULL;
}
MAILBOX_NOSELECT)) == 0)
return info;
}
i_error("quota: Listing namespace '%s' failed: %s",
}
/* if the namespace prefix itself exists, count it also */
}
/* try the next namespace */
return quota_mailbox_iter_next(iter);
}
{
struct quota_mailbox_iter *iter;
const struct mailbox_info *info;
int ret = 0;
if (root->recounting)
return 0;
}
return ret;
}
static struct quota_root *count_quota_alloc(void)
{
}
const char **error_r)
{
*error_r = "quota count backend requires quota_vsizes=yes";
return -1;
}
}
{
}
static const char *const *
{
static const char *resources[] = {
};
return resources;
}
static int
{
return -1;
else
return 0;
return 1;
}
{
struct mail_index_transaction *trans;
struct mailbox_metadata metadata;
struct mailbox_index_vsize vsize_hdr;
const char *errstr;
enum mail_error error;
if (mailbox_open(box) < 0) {
if (error != MAIL_ERROR_TEMP) {
/* non-temporary error, e.g. ACLs denied access. */
return 0;
}
return -1;
}
/* reset the vsize header first */
if (mail_index_transaction_commit(&trans) < 0)
return -1;
/* getting the vsize now forces its recalculation */
&metadata) < 0) {
return -1;
}
/* call sync to write the change to mailbox list index */
return -1;
}
return 0;
}
{
struct quota_mailbox_iter *iter;
const struct mailbox_info *info;
int ret = 0;
if (quota_count_recalculate_box(box) < 0)
ret = -1;
mailbox_free(&box);
}
return ret;
}
static int
struct quota_transaction_context *ctx)
{
if (ctx->recalculate) {
if (quota_count_recalculate(root) < 0)
return -1;
}
return 0;
}
struct quota_backend quota_backend_count = {
"count",
{
NULL,
NULL,
NULL,
NULL,
}
};