/* If user is under quota before saving a mail, allow the last mail to
bring the user over quota by this many bytes. */
- uint64_t last_mail_max_extra_bytes;
- struct quota_rule grace_rule;
+ uint64_t quota_storage_grace;
/* TRUE if any of the warning_rules have reverse==TRUE */
bool have_reverse_warnings:1;
/* how many bytes/mails can be saved until limit is reached.
(set once, not updated by bytes_used/count_used).
- if last_mail_max_extra_bytes>0, the bytes_ceil is initially
+ if quota_storage_grace>0, the bytes_ceil is initially
increased by that much, while bytes_ceil2 contains the real ceiling.
after the first allocation is done, bytes_ceil is set to
bytes_ceil2. */
/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
+#include "str-parse.h"
#include "wildcard-match.h"
#include "quota-private.h"
#include <ctype.h>
-#define QUOTA_DEFAULT_GRACE "10%"
+#define QUOTA_DEFAULT_GRACE "10M"
#define RULE_NAME_DEFAULT_FORCE "*"
quota_rule_recalculate_relative_rules(&warning_rule->rule,
bytes_limit, count_limit);
}
- quota_rule_recalculate_relative_rules(&root_set->grace_rule,
- bytes_limit, 0);
- root_set->last_mail_max_extra_bytes = root_set->grace_rule.bytes_limit;
e_debug(event,
"Quota root %s: Recalculated relative rules with "
- "bytes=%lld count=%lld. Now grace=%"PRIu64, root_set->name,
- (long long)bytes_limit, (long long)count_limit,
- root_set->last_mail_max_extra_bytes);
+ "bytes=%lld count=%lld.", root_set->name,
+ (long long)bytes_limit, (long long)count_limit);
}
static int
struct quota_root_settings *root_set,
const char *value, const char **error_r)
{
- const char *p;
-
if (value == NULL) {
/* default */
value = QUOTA_DEFAULT_GRACE;
}
- if (str_parse_int64(value, &root_set->grace_rule.bytes_limit, &p) < 0)
- return -1;
- if (quota_limit_parse(root_set, &root_set->grace_rule, p, 1,
- &root_set->grace_rule.bytes_limit, error_r) < 0)
+ if (str_parse_get_size(value, &root_set->quota_storage_grace,
+ error_r) < 0)
return -1;
- quota_rule_recalculate_relative_rules(&root_set->grace_rule,
- root_set->default_rule.bytes_limit, 0);
- root_set->last_mail_max_extra_bytes = root_set->grace_rule.bytes_limit;
- e_debug(event, "Quota grace: root=%s bytes=%lld%s",
- root_set->name, (long long)root_set->grace_rule.bytes_limit,
- root_set->grace_rule.bytes_percent == 0 ? "" :
- t_strdup_printf(" (%u%%)", root_set->grace_rule.bytes_percent));
+ e_debug(event, "Quota grace: root=%s bytes=%"PRIu64,
+ root_set->name, root_set->quota_storage_grace);
return 0;
}