aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-11-20 18:25:58 +0200
committerSergey Poznyakoff <gray@gnu.org>2021-11-20 18:32:20 +0200
commite39c0abb651f7b6caf633b968af442a49859e849 (patch)
tree0504a7b36bc665d97d66037a2a899038c94344e4
parent02d6d4bfd6256b30ca2a2ac56d8f12a51fe6ec7d (diff)
downloadmbar-master.tar.gz
mbar-master.tar.bz2
Fix directory scanner to work with mailutils 3.13HEADmaster
Since mailutils commit 3f74f2ada1, folder scan returns base file names (without the directory part). This fix rewrites enumfun taking this into account. The new approach should work with older mailutils versions as well, although I didn't test it. The recommended mailutils version is 3.13.90 (after commit 8d195a093d), anyway.
-rw-r--r--mbar.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/mbar.c b/mbar.c
index 81a474d..25db9dc 100644
--- a/mbar.c
+++ b/mbar.c
@@ -362,24 +362,21 @@ enumfun (mu_folder_t folder, struct mu_list_response *resp, void *data)
RESP_DEPTH (resp),
resp->name);
- rc = mu_mailbox_create (&mbox, resp->name);
+ rc = mu_mailbox_create_at (&mbox, folder, resp->name);
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create", resp->name, rc);
return 0;
}
- if (dry_run)
- rc = mu_mailbox_open (mbox, MU_STREAM_READ);
- else
- rc = mu_mailbox_open (mbox, MU_STREAM_RDWR);
+ rc = mu_mailbox_open (mbox, dry_run ? MU_STREAM_READ : MU_STREAM_RDWR);
if (rc)
abend ("mu_mailbox_open", resp->name, rc);
mu_mailbox_get_url (mbox, &url);
+ mu_url_sget_path (url, &path);
if (geteuid () == 0)
{
- mu_url_sget_path (url, &path);
if (stat (path, &st))
{
mu_diag_funcall (MU_DIAG_ERROR, "stat", path, errno);
@@ -401,12 +398,14 @@ enumfun (mu_folder_t folder, struct mu_list_response *resp, void *data)
if (rc)
mu_diag_funcall (MU_DIAG_ERROR, "mu_registrar_set_default_scheme",
scheme, rc);
- mu_url_destroy (&url);
if (rc)
- return 0;
+ {
+ mu_url_destroy (&url);
+ return 0;
+ }
}
-
- mach = build_sieve (resp->name, FLG_MKDIR);
+
+ mach = build_sieve (path, FLG_MKDIR);
rc = mu_sieve_mailbox (mach, mbox);
@@ -419,7 +418,9 @@ enumfun (mu_folder_t folder, struct mu_list_response *resp, void *data)
}
mu_sieve_machine_destroy (&mach);
-
+ mu_mailbox_close (mbox);
+ mu_mailbox_destroy (&mbox);
+
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.