This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=eed8a3dcd60e0bede0df3bd8e867a8eff62a7be6 The branch, master has been updated via eed8a3dcd60e0bede0df3bd8e867a8eff62a7be6 (commit) via 9ba3833f715a2aa929d6e51655cf44af1cfe9a2f (commit) from 3f1e6e4206f0d8306b650490704a46209d3c1e70 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit eed8a3dcd60e0bede0df3bd8e867a8eff62a7be6 Author: Sergey Poznyakoff <g...@gnu.org.ua> Date: Mon Dec 19 12:41:13 2016 +0200 Fix size calculation for MH and Maildir mailboxes Exclude from calculation any eventual nested mailboxes. * libproto/maildir/mbox.c: Provide the mailbox_size method. * libproto/mh/mbox.c: Likewise. commit 9ba3833f715a2aa929d6e51655cf44af1cfe9a2f Author: Sergey Poznyakoff <g...@gnu.org.ua> Date: Mon Dec 19 10:49:04 2016 +0200 Bugfixes * configure.ac: Fallback to guile installation prefix, if 'guile-config info bindir' returns empty string. * doc/texinfo/programs.texi: Minor fix. * mail/mailline.c (ml_readline_init): Don't use obsolete CPPFunction type. * mu/shell.c (mutool_initialize_readline): Likewise. * scheme/sieve2scm.scmi: Fix typo. * sieve/sieve.c (main): Fix initialization of Sieve environment variables "location" and "post". ----------------------------------------------------------------------- Summary of changes: configure.ac | 3 + doc/texinfo/programs.texi | 2 +- libproto/maildir/mbox.c | 207 +++++++++++++++++++++++++++++++++++---------- libproto/mh/mbox.c | 68 ++++++++++++++- mail/mailline.c | 3 +- mu/shell.c | 3 +- scheme/sieve2scm.scmi | 2 +- sieve/sieve.c | 5 +- 8 files changed, 243 insertions(+), 50 deletions(-) diff --git a/configure.ac b/configure.ac index 2327ca0..00fc7a1 100644 --- a/configure.ac +++ b/configure.ac @@ -1159,6 +1159,9 @@ GINT_INIT([gint],[1.8 with-guile], [useguile=yes AC_DEFINE([WITH_GUILE],1,[Enable Guile support]) GUILE_BINDIR=`guile-config info bindir` + if [ -z "$GUILE_BINDIR" ]; then + GUILE_BINDIR="`guile-config info prefix`/bin" + fi LIBMU_SCM=../libmu_scm/libmu_scm.la LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}' MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/$(PACKAGE)/sieve-modules' diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi index 2e4db32..1afb2ba 100644 --- a/doc/texinfo/programs.texi +++ b/doc/texinfo/programs.texi @@ -5659,7 +5659,7 @@ Keep on going if execution fails on a message. See also @ref{Sieve Configuration, keep-going}. @item -L @var{dir} -@item --libdir=@var{dir} +@itemx --libdir=@var{dir} Append directory @var{dir} to the list of directories searched for library files. See also @ref{Sieve Configuration, library-path}. diff --git a/libproto/maildir/mbox.c b/libproto/maildir/mbox.c index 028a0f4..fe0bc2c 100644 --- a/libproto/maildir/mbox.c +++ b/libproto/maildir/mbox.c @@ -666,44 +666,63 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir, char *dirname) size_t index; int rc = 0; int need_sort = 0; + struct stat st; while ((entry = readdir (dir))) { - switch (entry->d_name[0]) + char *fname; + + if (entry->d_name[0] == '.') + continue; + + rc = maildir_mkfilename (amd->name, dirname, entry->d_name, &fname); + if (rc) { - case '.': - break; + mu_diag_funcall (MU_DIAG_ERROR, "maildir_mkfilename", + entry->d_name, rc); + continue; + } + + if (stat (fname, &st)) + { + rc = errno; + mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR, + ("can't stat %s: %s", fname, mu_strerror (rc))); + free (fname); + continue; + } - default: - /* Message not found. Index points to the array cell where it - would be placed */ - msg = calloc (1, sizeof (*msg)); - if (!msg) - { - rc = ENOMEM; - break; - } - key.file_name = entry->d_name; - if (!amd_msg_lookup (amd, (struct _amd_message *) &key, &index)) - continue; - rc = _amd_message_append (amd, (struct _amd_message *) msg); - if (rc) - { - free (msg); - break; - } - - msg->dir = dirname; - msg->file_name = strdup (entry->d_name); + free (fname); - p = maildir_name_info_ptr (msg->file_name); - if (p) - msg->amd_message.attr_flags = info_to_flags (p); - else - msg->amd_message.attr_flags = 0; - msg->amd_message.orig_flags = msg->amd_message.attr_flags; - need_sort = 1; + if (!S_ISREG (st.st_mode)) + continue; + + msg = calloc (1, sizeof (*msg)); + if (!msg) + { + rc = ENOMEM; + break; } + key.file_name = entry->d_name; + if (!amd_msg_lookup (amd, (struct _amd_message *) &key, &index)) + continue; + rc = _amd_message_append (amd, (struct _amd_message *) msg); + if (rc) + { + free (msg); + break; + } + + msg->dir = dirname; + msg->file_name = strdup (entry->d_name); + + p = maildir_name_info_ptr (msg->file_name); + if (p) + msg->amd_message.attr_flags = info_to_flags (p); + else + msg->amd_message.attr_flags = 0; + msg->amd_message.orig_flags = msg->amd_message.attr_flags; + need_sort = 1; } if (rc == 0 && need_sort) @@ -712,9 +731,7 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir, char *dirname) } static int -maildir_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, - size_t *pcount, - int do_notify) +maildir_scan_unlocked (mu_mailbox_t mailbox, size_t *pcount, int do_notify) { struct _amd_data *amd = mailbox->data; DIR *dir; @@ -723,12 +740,6 @@ maildir_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, struct stat st; size_t i; - if (amd == NULL) - return EINVAL; - if (mailbox->flags & MU_STREAM_APPEND) - return 0; - mu_monitor_wrlock (mailbox->monitor); - /* 1st phase: Flush tmp/ */ maildir_flush (amd); @@ -748,11 +759,11 @@ maildir_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, } free (name); + /* 3rd phase: Scan cur/ */ status = maildir_mkfilename (amd->name, CURSUF, NULL, &name); if (status) return status; - /* 3rd phase: Scan cur/ */ status = maildir_opendir (&dir, name, PERMS | mu_stream_flags_to_mode (mailbox->flags, 1)); @@ -778,11 +789,120 @@ maildir_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, if (pcount) *pcount = amd->msg_count; - /* Clean up the things */ - amd_cleanup (mailbox); return status; } +static int +maildir_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, + size_t *pcount, + int do_notify) +{ + struct _amd_data *amd = mailbox->data; + int rc; + + if (amd == NULL) + return EINVAL; + if (mailbox->flags & MU_STREAM_APPEND) + return 0; + mu_monitor_wrlock (mailbox->monitor); + rc = maildir_scan_unlocked (mailbox, pcount, do_notify); + mu_monitor_unlock (mailbox->monitor); + return rc; +} + +static int +maildir_size_dir (struct _amd_data *amd, char *dirsuf, mu_off_t *psize) +{ + DIR *dir; + struct dirent *entry; + int rc = 0; + struct stat st; + char *name; + + rc = maildir_mkfilename (amd->name, dirsuf, NULL, &name); + if (rc) + return rc; + dir = opendir (name); + + if (!dir) + { + rc = errno; + mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR, + ("can't open directory %s: %s", name, mu_strerror (rc))); + free (name); + if (rc == ENOENT) + return 0; + return rc; + } + + while ((entry = readdir (dir))) + { + char *fname; + + if (entry->d_name[0] == '.') + continue; + + rc = maildir_mkfilename (amd->name, dirsuf, entry->d_name, &fname); + if (rc) + { + mu_diag_funcall (MU_DIAG_ERROR, "maildir_mkfilename", + entry->d_name, rc); + continue; + } + + if (stat (fname, &st)) + { + rc = errno; + mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR, + ("can't stat %s: %s", fname, mu_strerror (rc))); + free (fname); + continue; + } + + free (fname); + + if (S_ISREG (st.st_mode)) + *psize += st.st_size; + } + + closedir (dir); + free (name); + + return 0; +} + +static int +maildir_size_unlocked (struct _amd_data *amd, mu_off_t *psize) +{ + mu_off_t size = 0; + int rc; + + rc = maildir_size_dir (amd, NEWSUF, &size); + if (rc) + return rc; + rc = maildir_size_dir (amd, CURSUF, &size); + if (rc) + return rc; + *psize = size; + return 0; +} + +static int +maildir_size (mu_mailbox_t mailbox, mu_off_t *psize) +{ + struct _amd_data *amd = mailbox->data; + int rc; + + if (amd == NULL) + return EINVAL; + + mu_monitor_wrlock (mailbox->monitor); + rc = maildir_size_unlocked (amd, psize); + mu_monitor_unlock (mailbox->monitor); + + return rc; +} + static int maildir_qfetch (struct _amd_data *amd, mu_message_qid_t qid) @@ -926,6 +1046,7 @@ _mailbox_maildir_init (mu_mailbox_t mailbox) amd->remove = maildir_remove; amd->chattr_msg = maildir_chattr_msg; amd->capabilities = MU_AMD_STATUS; + amd->mailbox_size = maildir_size; /* Set our properties. */ { diff --git a/libproto/mh/mbox.c b/libproto/mh/mbox.c index 5eeea5d..6131bc7 100644 --- a/libproto/mh/mbox.c +++ b/libproto/mh/mbox.c @@ -62,6 +62,7 @@ #include <mailutils/observer.h> #include <mailutils/io.h> #include <mailutils/cctype.h> +#include <mailutils/cstr.h> #include <mailutils/mh.h> #include <mailutils/sys/mailbox.h> #include <mailutils/sys/registrar.h> @@ -281,14 +282,78 @@ mh_scan0 (mu_mailbox_t mailbox, size_t msgno MU_ARG_UNUSED, size_t *pcount, } /* Clean up the things */ + mu_locker_unlock (mailbox->locker); amd_cleanup (mailbox); #ifdef WITH_PTHREAD pthread_cleanup_pop (0); #endif return status; } + +static int +mh_size_unlocked (struct _amd_data *amd, mu_off_t *psize) +{ + mu_off_t size = 0; + int rc; + struct stat st; + DIR *dir; + struct dirent *entry; + + dir = opendir (amd->name); + if (!dir) + return errno; + + while ((entry = readdir (dir))) + { + if (*mu_str_skip_class (entry->d_name, MU_CTYPE_DIGIT) == 0) + { + char *fname = mu_make_file_name (amd->name, entry->d_name); + if (!fname) + continue; + if (stat (fname, &st)) + { + rc = errno; + mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR, + ("can't stat %s: %s", fname, mu_strerror (rc))); + free (fname); + continue; + } + if (S_ISREG (st.st_mode)) + size += st.st_size; + } + } + + *psize = size; + + closedir (dir); + + return 0; +} static int +mh_size (mu_mailbox_t mailbox, mu_off_t *psize) +{ + struct _amd_data *amd = mailbox->data; + int rc; + + mu_monitor_wrlock (mailbox->monitor); +#ifdef WITH_PTHREAD + pthread_cleanup_push (amd_cleanup, (void *)mailbox); +#endif + mu_locker_lock (mailbox->locker); + + rc = mh_size_unlocked (amd, psize); + + mu_locker_unlock (mailbox->locker); + mu_monitor_unlock (mailbox->monitor); +#ifdef WITH_PTHREAD + pthread_cleanup_pop (0); +#endif + return rc; +} + + +static int mh_qfetch (struct _amd_data *amd, mu_message_qid_t qid) { char *p; @@ -467,7 +532,8 @@ _mailbox_mh_init (mu_mailbox_t mailbox) amd->message_uid = mh_message_uid; amd->next_uid = _mh_next_seq; amd->remove = mh_remove; - + amd->mailbox_size = mh_size; + mailbox->_get_property = mh_get_property; mailbox->_translate = mh_translate; diff --git a/mail/mailline.c b/mail/mailline.c index ae9a8f8..0119a7c 100644 --- a/mail/mailline.c +++ b/mail/mailline.c @@ -93,7 +93,8 @@ ml_readline_init () #ifdef WITH_READLINE rl_readline_name = "mail"; - rl_attempted_completion_function = (CPPFunction*)ml_command_completion; + rl_attempted_completion_function = + (rl_completion_func_t*) ml_command_completion; rl_getc_function = ml_getc; #endif #ifdef HAVE_SIGACTION diff --git a/mu/shell.c b/mu/shell.c index 276057b..ba65713 100644 --- a/mu/shell.c +++ b/mu/shell.c @@ -332,7 +332,8 @@ mutool_initialize_readline (const char *name) { /* Allow conditional parsing of the ~/.inputrc file. */ rl_readline_name = (char *) name; - rl_attempted_completion_function = (CPPFunction *) shell_completion; + rl_attempted_completion_function = + (rl_completion_func_t*) shell_completion; rl_getc_function = _shell_getc; read_history (get_history_file_name ()); } diff --git a/scheme/sieve2scm.scmi b/scheme/sieve2scm.scmi index 731fe53..c894adb 100644 --- a/scheme/sieve2scm.scmi +++ b/scheme/sieve2scm.scmi @@ -981,7 +981,7 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n") (define output #f) (define (sieve-usage) - (display "usage: sieve2scm [OPTIONS][mailbox]\n") + (display "usage: sieve2scm [OPTIONS] [mailbox]\n") (display "GNU sieve2scm -- compile a Sieve program into Scheme code\n\n") (display " -f, --file FILENAME Set input file name\n") (display " -o, --output FILENAME Set output file name\n") diff --git a/sieve/sieve.c b/sieve/sieve.c index dc429a6..c74f7c3 100644 --- a/sieve/sieve.c +++ b/sieve/sieve.c @@ -485,8 +485,9 @@ main (int argc, char *argv[]) return EX_SOFTWARE; } - sieve_setenv ("location=MS", mach); - sieve_setenv ("phase=post", mach); + mu_sieve_set_environ (mach, "location", "MS"); + mu_sieve_set_environ (mach, "phase", "post"); + mu_list_foreach (env_list, sieve_setenv, mach); mu_list_destroy (&env_list); hooks/post-receive -- GNU Mailutils _______________________________________________ Commit-mailutils mailing list Commit-mailutils@gnu.org https://lists.gnu.org/mailman/listinfo/commit-mailutils