summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-05-03 08:45:36 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-03 08:45:36 (GMT)
commitbf87c2f6634b992252857076a5eadc6d16e9e9df (patch) (side-by-side diff)
tree0e39021ea0333cfd7b6f6584d847d7e6599ec8a4
parentd00c27dc1de008ac2e4e5b6dba291c6552ff5011 (diff)
downloadmailutils-bf87c2f6634b992252857076a5eadc6d16e9e9df.tar.gz
mailutils-bf87c2f6634b992252857076a5eadc6d16e9e9df.tar.bz2
movemail: make sure UIDLs are properly stored.
* movemail/movemail.c (main): When using POP3 UIDLs for message identification, be sure to store them in the X-UIDL header.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--movemail/movemail.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/movemail/movemail.c b/movemail/movemail.c
index 5aad96d..0c31786 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -1052,7 +1052,8 @@ main (int argc, char **argv)
{
struct mu_uidl *uidl;
mu_message_t msg;
-
+ mu_header_t hdr;
+
mu_iterator_current (itr, (void **)&uidl);
if ((rc = mu_mailbox_get_message (source, uidl->msgno, &msg)) != 0)
@@ -1062,6 +1063,40 @@ main (int argc, char **argv)
get_err_count++;
continue;
}
+
+ /* Check if the downloaded message has X-UIDL header. If not,
+ add one. This check should disappear one mailutils implements
+ alternative storage for mailbox meta-data. */
+ if ((rc = mu_message_get_header (msg, &hdr)))
+ {
+ mu_error (_("%lu: cannot get header: %s"),
+ (unsigned long) uidl->msgno, mu_strerror (rc));
+ }
+ else
+ {
+ char const *suidl = NULL;
+
+ if ((rc = mu_header_sget_value (hdr, MU_HEADER_X_UIDL, &suidl)))
+ {
+ if (rc != MU_ERR_NOENT)
+ mu_error (_("%lu: cannot get %s: %s"),
+ (unsigned long) uidl->msgno, MU_HEADER_X_UIDL,
+ mu_strerror (rc));
+ }
+ else if (strcmp (suidl, uidl->uidl))
+ {
+ mu_error (_("%lu: stored and reported UIDL differ; fixing"),
+ (unsigned long) uidl->msgno);
+ suidl = NULL;
+ }
+
+ if ((rc = mu_header_set_value (hdr, MU_HEADER_X_UIDL,
+ uidl->uidl, 1)))
+ {
+ mu_error (_("%lu: cannot set header: %s"),
+ (unsigned long) uidl->msgno, mu_strerror (rc));
+ }
+ }
progress_mark (itr);
if (movemail (dest, msg, uidl->msgno))
break;

Return to:

Send suggestions and report system problems to the System administrator.