Skip to content

Commit

Permalink
quota: add '-n' to report differences without fixing things!
Browse files Browse the repository at this point in the history
  • Loading branch information
brong committed Jun 13, 2019
1 parent 1479d8d commit 23d6ef9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docsrc/imap/reference/manpages/systemcommands/quota.rst
Expand Up @@ -64,6 +64,11 @@ Options
Fix any inconsistencies in the quota subsystem before generating a
report.

.. option:: -n

Check for any inconsistencies in the quota subsystem but don't actually
fix them. Use with **-f** and **-q** to only see what's incorrect.

.. option:: -q

Operate quietly. If **-f** is specified, then don't print the quota
Expand Down
11 changes: 9 additions & 2 deletions imap/quota.c
Expand Up @@ -116,6 +116,7 @@ static int (*compar)(const char *s1, const char *s2);
static struct quotaentry *quotaroots;
static int quota_num = 0, quota_alloc = 0;
static int quota_todo = 0;
static int flag_reportonly = 0;

static int test_sync_mode = 0;

Expand Down Expand Up @@ -153,6 +154,10 @@ int main(int argc,char **argv)
isuser = 1;
break;

case 'n':
flag_reportonly = 1;
break;

case 'J':
jsonout = json_object();
break;
Expand Down Expand Up @@ -563,7 +568,8 @@ int fixquota_finish(int thisquota)
if (!quotaroots[thisquota].refcount) {
quotaroots[thisquota].deleted = 1;
fprintf(stderr, "%s: removed\n", root);
r = quota_deleteroot(root, 0);
if (!flag_reportonly)
r = quota_deleteroot(root, 0);
if (r) {
errmsg("failed deleting quotaroot '%s'", root, r);
}
Expand All @@ -586,7 +592,8 @@ int fixquota_finish(int thisquota)
quota_names[res],
localq.useds[res],
localq.scanuseds[res]);
localq.useds[res] = localq.scanuseds[res];
if (!flag_reportonly)
localq.useds[res] = localq.scanuseds[res];
}
}

Expand Down

0 comments on commit 23d6ef9

Please sign in to comment.