diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-12-21 23:38:42 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-12-21 23:38:42 +0200 |
commit | 317bb197a7f288aa4d36d4af7849e90e14fd7a77 (patch) | |
tree | 583771cfe7e614587685e97b8feddd1eb66fbcdd /libmailutils | |
parent | 35b8dcfbe745d59faa4fde8d76b30c5781d5cd8d (diff) | |
download | mailutils-317bb197a7f288aa4d36d4af7849e90e14fd7a77.tar.gz mailutils-317bb197a7f288aa4d36d4af7849e90e14fd7a77.tar.bz2 |
MH: provide a mh_profile setting to control assignment of sequence numbers
The "Volatile-uidnext" setting controls how sequence numbers are allocated.
By default they increase monotonically. If Volatile-uidnext is set to
"true", each new incorporated message is assigned the sequence number equal
to that of the last message increased by one. When the last message in
the mailbox is deleted, the value of UIDNEXT is recalculated and
UIDVALIDITY is increased. This follows the behavior of traditional MH
implementations.
* doc/texinfo/mu-mh.texi: Document chnges.
* include/mailutils/sys/amd.h (MU_AMD_VOLATILE_UIDNEXT): New
constant.
* libmailutils/base/amd.c (amd_expunge): Reset uidvalidity and uidnext
if MU_AMD_VOLATILE_UIDNEXT capability is set and the last message
was removed.
* libproto/mh/mh.c (_mailbox_mh_init): New mh_profile setting
"Volatile-uidnext". If set to true, it instructs mailutils to
mimic the traditional MH behavior when assigning sequence number
to the new message.
* testsuite/mbop.c (main): Use MBOP_PRE_OPEN_HOOK (if defined) as
the name of the function to call before opening the mailbox.
* libproto/mh/tests/mbop.c (mbop_pre_open_hook): New function.
If the MH environment variable is set, take its value as the name
of the mh_profile and read settings from it.
* libproto/mh/tests/Makefile.am: Add uidvol.at
* libproto/mh/tests/atlocal.in: Unset MH.
* libproto/mh/tests/testsuite.at: Include uidvol.at
* libproto/mh/tests/uidvol.at: New file.
Diffstat (limited to 'libmailutils')
-rw-r--r-- | libmailutils/base/amd.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libmailutils/base/amd.c b/libmailutils/base/amd.c index ee32d2917..52531536f 100644 --- a/libmailutils/base/amd.c +++ b/libmailutils/base/amd.c @@ -1410,7 +1410,16 @@ amd_expunge (mu_mailbox_t mailbox) if (expcount) { + int reset_uidvalidity; + last_expunged++; + + /* See the description of MU_AMD_VOLATILE_UIDNEXT in amd.h for + details. + */ + reset_uidvalidity = (amd->capabilities & MU_AMD_VOLATILE_UIDNEXT) + && last_expunged == amd->msg_count; + do { size_t j; @@ -1425,6 +1434,18 @@ amd_expunge (mu_mailbox_t mailbox) ; } while (last_expunged); + + if (reset_uidvalidity) + { + /* + * The following is equivalent to + * mu_mailbox_uidvalidity_reset (amd->mailbox); + */ + + struct timeval tv; + gettimeofday (&tv, NULL); + amd_set_uidvalidity (amd->mailbox, tv.tv_sec); + } } if (updated && !amd->mailbox_size) |