]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Add error_r to update() of quota_backend_vfuncs
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Mon, 16 Oct 2017 09:38:32 +0000 (12:38 +0300)
committerTimo Sirainen <tss@dovecot.fi>
Thu, 19 Oct 2017 13:43:45 +0000 (16:43 +0300)
src/plugins/quota/doveadm-quota.c
src/plugins/quota/quota-count.c
src/plugins/quota/quota-dict.c
src/plugins/quota/quota-dirsize.c
src/plugins/quota/quota-fs.c
src/plugins/quota/quota-imapc.c
src/plugins/quota/quota-maildir.c
src/plugins/quota/quota-private.h
src/plugins/quota/quota.c

index f1d725cca6a4b050a0ad6b013b49426e3518b3a8..9d3eb96837e7468d1e13e9a0330c30cb37b9dfc9 100644 (file)
@@ -107,7 +107,9 @@ cmd_quota_recalc_run(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
        trans.recalculate = QUOTA_RECALCULATE_FORCED;
 
        array_foreach(&quser->quota->roots, root) {
-               (void)(*root)->backend.v.update(*root, &trans);
+               const char *error;
+               if ((*root)->backend.v.update(*root, &trans, &error) < 0)
+                       i_error("Recalculating quota failed: %s", error);
                if ((*root)->backend.v.flush != NULL)
                        (*root)->backend.v.flush(*root);
        }
index a034126910b9468dece6b4bbd479c20ac505f1ea..4005be372d5f30488942444af491ceb8fabbb8cf 100644 (file)
@@ -312,14 +312,17 @@ static int quota_count_recalculate(struct quota_root *root)
 
 static int
 count_quota_update(struct quota_root *root,
-                  struct quota_transaction_context *ctx)
+                  struct quota_transaction_context *ctx,
+                  const char **error_r)
 {
        struct count_quota_root *croot = (struct count_quota_root *)root;
 
        croot->cache_timeval.tv_sec = 0;
        if (ctx->recalculate == QUOTA_RECALCULATE_FORCED) {
-               if (quota_count_recalculate(root) < 0)
+               if (quota_count_recalculate(root) < 0) {
+                       *error_r = "Calculating quota failed";
                        return -1;
+               }
        }
        return 0;
 }
index ece6ceea891cc8d3cd03c9b01e15ee505333c699..5cb7728a946d2abdea416fafbb705e55a0895b3a 100644 (file)
@@ -207,15 +207,18 @@ static void dict_quota_update_callback(const struct dict_commit_result *result,
 
 static int
 dict_quota_update(struct quota_root *_root, 
-                 struct quota_transaction_context *ctx)
+                 struct quota_transaction_context *ctx,
+                 const char **error_r)
 {
        struct dict_quota_root *root = (struct dict_quota_root *) _root;
        struct dict_transaction_context *dt;
        uint64_t value;
 
        if (ctx->recalculate != QUOTA_RECALCULATE_DONT) {
-               if (dict_quota_count(root, TRUE, &value) < 0)
+               if (dict_quota_count(root, TRUE, &value) < 0) {
+                       *error_r = "Dict quota count failed";
                        return -1;
+               }
        } else {
                dt = dict_transaction_begin(root->dict);
                if (ctx->bytes_used != 0) {
index 489420b8418140913ace17acfc33498d647bd3fb..7ac4e3d8e2e87772f708f1853950623bdf5cf3a3 100644 (file)
@@ -209,7 +209,8 @@ dirsize_quota_get_resource(struct quota_root *_root, const char *name,
 
 static int 
 dirsize_quota_update(struct quota_root *root ATTR_UNUSED, 
-                    struct quota_transaction_context *ctx ATTR_UNUSED)
+                    struct quota_transaction_context *ctx ATTR_UNUSED,
+                    const char **error_r ATTR_UNUSED)
 {
        return 0;
 }
index 3e4119c11c626f1992577d9a5a6d448ace89383d..a5563adf22af515c91cd6da0a32890bc98ef8d95 100644 (file)
@@ -911,7 +911,8 @@ fs_quota_get_resource(struct quota_root *_root, const char *name,
 
 static int
 fs_quota_update(struct quota_root *root ATTR_UNUSED,
-               struct quota_transaction_context *ctx ATTR_UNUSED)
+               struct quota_transaction_context *ctx ATTR_UNUSED,
+               const char **error_r ATTR_UNUSED)
 {
        return 0;
 }
index 6e8deb858c648e393344149285450e4677a54b99..74ed25fe4de8afe0fa60a11469860608f39e2ead 100644 (file)
@@ -443,7 +443,8 @@ imapc_quota_get_resource(struct quota_root *_root, const char *name,
 
 static int
 imapc_quota_update(struct quota_root *root ATTR_UNUSED,
-                  struct quota_transaction_context *ctx ATTR_UNUSED)
+                  struct quota_transaction_context *ctx ATTR_UNUSED,
+                  const char **error_r ATTR_UNUSED)
 {
        return 0;
 }
index d279222ee8d4c6e4cbc3bd847246160450d3bbc5..876dc60b22692049df8fa082e192578e51366903 100644 (file)
@@ -857,7 +857,8 @@ maildir_quota_get_resource(struct quota_root *_root, const char *name,
 
 static int
 maildir_quota_update(struct quota_root *_root,
-                    struct quota_transaction_context *ctx)
+                    struct quota_transaction_context *ctx,
+                    const char **error_r)
 {
        struct maildir_quota_root *root = (struct maildir_quota_root *)_root;
        bool recalculated;
@@ -871,8 +872,10 @@ maildir_quota_update(struct quota_root *_root,
           we do want to make sure the header gets updated if the limits have
           changed. also this makes sure the maildirsize file is created if
           it doesn't exist. */
-       if (maildirquota_refresh(root, &recalculated) < 0)
+       if (maildirquota_refresh(root, &recalculated) < 0) {
+               *error_r = "Failed to refresh maildir quota";
                return -1;
+       }
 
        if (recalculated) {
                /* quota was just recalculated and it already contains the changes
index 2c14ce43533d567e94667be6d3a2e90fa3680f03..41e9ddfb032904b5a71f2d4b6b36bf71e4cfbff6 100644 (file)
@@ -73,7 +73,8 @@ struct quota_backend_vfuncs {
                            const char **error_r);
 
        int (*update)(struct quota_root *root, 
-                     struct quota_transaction_context *ctx);
+                     struct quota_transaction_context *ctx,
+                     const char **error_r);
        bool (*match_box)(struct quota_root *root, struct mailbox *box);
        void (*flush)(struct quota_root *root);
 };
index c5df7f5384253c5f55d1c0078bdc18059fb7820c..988328c61563380a8cffed54d0e1b34b7c804653 100644 (file)
@@ -1137,8 +1137,12 @@ int quota_transaction_commit(struct quota_transaction_context **_ctx)
                                continue;
                        }
 
-                       if (roots[i]->backend.v.update(roots[i], ctx) < 0)
+                       const char *error;
+                       if (roots[i]->backend.v.update(roots[i], ctx, &error) < 0) {
+                               i_error("Failed to update quota for %s: %s",
+                                       mailbox_name, error);
                                ret = -1;
+                       }
                        else if (!ctx->sync_transaction)
                                array_append(&warn_roots, &roots[i], 1);
                }