summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-18 18:26:24 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-18 18:29:28 +0200
commitfa1383a029fe511cf68497423b6e37d8ca0e8595 (patch)
tree1c1b703cfa23e997807dc96afd3e014aaaca1c62
parentfed1cb2229bfc4eacc035b395e1b1bb2b34f7a72 (diff)
downloadmailutils-fa1383a029fe511cf68497423b6e37d8ca0e8595.tar.gz
mailutils-fa1383a029fe511cf68497423b6e37d8ca0e8595.tar.bz2
maildir: assign UID to the message file before moving it from new to cur
* libproto/maildir/mbox.c (maildir_scan_unlocked): Assign next UID to the message before moving it from new to cur. * libproto/maildir/tests/new.at: New test. * libproto/maildir/tests/Makefile.am: Add nre test. * libproto/maildir/tests/testsuite.at: Likewise.
-rw-r--r--libproto/maildir/mbox.c5
-rw-r--r--libproto/maildir/tests/Makefile.am1
-rw-r--r--libproto/maildir/tests/new.at34
-rw-r--r--libproto/maildir/tests/testsuite.at1
4 files changed, 39 insertions, 2 deletions
diff --git a/libproto/maildir/mbox.c b/libproto/maildir/mbox.c
index 87edc4b38..978398ef3 100644
--- a/libproto/maildir/mbox.c
+++ b/libproto/maildir/mbox.c
@@ -849,7 +849,7 @@ maildir_message_fixup (struct _maildir_data *md, struct _maildir_message *msg)
else
md->next_uid = msg->uid + 1;
- if (update && md->amd.mailbox->flags & MU_STREAM_WRITE)
+ if (update && (md->amd.mailbox->flags & MU_STREAM_WRITE))
{
md->amd.chattr_msg (&msg->amd_message, 0);
}
@@ -896,8 +896,9 @@ maildir_scan_unlocked (mu_mailbox_t mailbox, size_t *pcount, int do_notify)
{
struct _maildir_message *msg = (struct _maildir_message *)
_amd_get_message (&md->amd, i);
- if (msg->subdir == SUB_NEW && md->amd.mailbox->flags & MU_STREAM_WRITE)
+ if (msg->subdir == SUB_NEW && (md->amd.mailbox->flags & MU_STREAM_WRITE))
{
+ msg->uid = md->next_uid++;
if (md->amd.chattr_msg (&msg->amd_message, 0) == 0)
has_new = 1;
}
diff --git a/libproto/maildir/tests/Makefile.am b/libproto/maildir/tests/Makefile.am
index c82fb1881..36ba27185 100644
--- a/libproto/maildir/tests/Makefile.am
+++ b/libproto/maildir/tests/Makefile.am
@@ -48,6 +48,7 @@ TESTSUITE_AT += \
envelope.at\
header.at\
notify.at\
+ new.at\
uid.at\
uidfixup.at\
uidvalidity.at\
diff --git a/libproto/maildir/tests/new.at b/libproto/maildir/tests/new.at
new file mode 100644
index 000000000..6a1c4e0ce
--- /dev/null
+++ b/libproto/maildir/tests/new.at
@@ -0,0 +1,34 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([deliver messages from new])
+AT_DATA([names],
+[cur/1284628225.M17468P3883Q0.Trurl,u=1:2,
+cur/1284628225.M19181P3883Q1.Trurl,u=20:2,S
+cur/1284628225.M20118P3883Q2.Trurl,u=22:2,
+cur/1284628225.M21284P3883Q3.Trurl,u=43:2,
+new/1284628225.M22502P3883Q4.Trurl
+])
+AT_CHECK([mbox2dir -i names -p -v 10 -u inbox $spooldir/mbox1])
+AT_CHECK([mbop -m inbox count \; 5 \; uid \; uidvalidity \; uidnext],
+[0],
+[count: 5
+5 current message
+5 uid: 44
+uidvalidity: 10
+uidnext: 45
+])
+AT_CLEANUP
diff --git a/libproto/maildir/tests/testsuite.at b/libproto/maildir/tests/testsuite.at
index 0242ce03f..c17fc7e65 100644
--- a/libproto/maildir/tests/testsuite.at
+++ b/libproto/maildir/tests/testsuite.at
@@ -29,6 +29,7 @@ m4_include([uid.at])
m4_include([uidvalidity.at])
m4_include([qget.at])
+m4_include([new.at])
m4_include([append.at])
m4_include([notify.at])
m4_include([delete.at])

Return to:

Send suggestions and report system problems to the System administrator.