Mercurial > dovecot > original-hg > dovecot-2.1
changeset 14946:2493ec20df8c
quota-status: If size parameter is given, use it to check quota.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 02 Apr 2013 11:52:36 +0300 |
parents | b2fad9b21e60 |
children | c7da636a09c4 |
files | src/plugins/quota/quota-status.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-status.c Tue Apr 02 11:32:24 2013 +0300 +++ b/src/plugins/quota/quota-status.c Tue Apr 02 11:52:36 2013 +0300 @@ -21,6 +21,7 @@ struct connection conn; char *recipient; + uoff_t size; }; static enum quota_protocol protocol; @@ -42,7 +43,8 @@ i_free_and_null(client->recipient); } -static int quota_check(struct mail_user *user, const char **error_r) +static int +quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r) { struct quota_user *quser = QUOTA_USER_CONTEXT(user); struct mail_namespace *ns; @@ -60,7 +62,7 @@ box = mailbox_alloc(ns->list, "INBOX", 0); ctx = quota_transaction_begin(box); - ret = quota_test_alloc(ctx, 1, &too_large); + ret = quota_test_alloc(ctx, I_MAX(1, mail_size), &too_large); quota_transaction_rollback(&ctx); mailbox_free(&box); @@ -95,7 +97,7 @@ o_stream_send_str(client->conn.output, "action=REJECT Unknown user\n\n"); } else if (ret > 0) { - if ((ret = quota_check(user, &error)) > 0) + if ((ret = quota_check(user, client->size, &error)) > 0) o_stream_send_str(client->conn.output, "action=OK\n\n"); else if (ret == 0) { o_stream_send_str(client->conn.output, t_strdup_printf( @@ -124,6 +126,10 @@ if (client->recipient == NULL && strncmp(line, "recipient=", 10) == 0) client->recipient = i_strdup(line + 10); + else if (strncmp(line, "size=", 5) == 0) { + if (str_to_uoff(line+5, &client->size) < 0) + client->size = 0; + } return 1; }