/* Copyright (c) 2006-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "mailbox-list-iter.h"
#include "quota-private.h"
struct count_quota_root {
};
struct quota_mailbox_iter {
unsigned int ns_idx;
const char *error;
};
extern struct quota_backend quota_backend_count;
static int
enum quota_get_result *error_result_r,
const char **error_r)
{
const char *errstr;
int ret;
/* mailbox not included in quota */
return 0;
}
ret = 0;
&metadata) < 0 ||
if (error == MAIL_ERROR_TEMP) {
"Couldn't get size of mailbox %s: %s",
ret = -1;
} else if (error == MAIL_ERROR_INUSE) {
/* started on background. don't log an error. */
"Ongoing quota calculation blocked getting size of %s: %s",
ret = -1;
} else {
/* non-temporary error, e.g. ACLs denied access. */
ret = 0;
}
} else {
ret = 0;
}
mailbox_free(&box);
return ret;
}
static struct quota_mailbox_iter *
{
return iter;
}
static int
const char **error_r)
{
"Listing namespace '%s' failed: %s",
ret = -1;
}
}
if (ret < 0) {
const char *separator =
}
return ret;
}
static const struct mailbox_info *
{
unsigned int count;
do {
return NULL;
}
MAILBOX_NOSELECT)) == 0)
return info;
}
"Listing namespace '%s' failed: %s",
}
/* if the namespace prefix itself exists, count it also */
}
/* try the next namespace */
return quota_mailbox_iter_next(iter);
}
{
if (root->recounting)
return 0;
&error1) < 0) {
ret = -1;
break;
}
}
ret = -1;
}
if (ret < 0) {
const char *separator =
}
return ret;
}
static enum quota_get_result
const char **error_r)
{
int ret;
ioloop_timeval.tv_sec != 0) {
return QUOTA_GET_RESULT_LIMITED;
}
if (ret < 0) {
return error_res;
} else if (ret > 0) {
}
return QUOTA_GET_RESULT_LIMITED;
}
{
}
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 enum quota_get_result
const char **error_r)
{
if (ret <= QUOTA_GET_RESULT_INTERNAL_ERROR)
return ret;
else {
}
return QUOTA_GET_RESULT_LIMITED;
}
const char **error_r)
{
const char *errstr;
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) {
"Couldn't commit mail index transaction for %s: %s",
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;
}
const char **error_r)
{
int ret = 0;
ret = -1;
mailbox_free(&box);
}
ret = -1;
if (ret < 0) {
const char *separator =
"quota-count: recalculate failed: %s%s%s",
}
return ret;
}
static int
struct quota_transaction_context *ctx,
const char **error_r)
{
return -1;
}
return 0;
}
.name = "count",
.v = {
.init = count_quota_init,
}
};