diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-03 11:45:36 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-03 11:45:36 +0300 |
commit | bf87c2f6634b992252857076a5eadc6d16e9e9df (patch) | |
tree | 0e39021ea0333cfd7b6f6584d847d7e6599ec8a4 | |
parent | d00c27dc1de008ac2e4e5b6dba291c6552ff5011 (diff) | |
download | mailutils-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.
-rw-r--r-- | movemail/movemail.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/movemail/movemail.c b/movemail/movemail.c index 5aad96d4e..0c3178604 100644 --- a/movemail/movemail.c +++ b/movemail/movemail.c | |||
@@ -1052,7 +1052,8 @@ main (int argc, char **argv) | |||
1052 | { | 1052 | { |
1053 | struct mu_uidl *uidl; | 1053 | struct mu_uidl *uidl; |
1054 | mu_message_t msg; | 1054 | mu_message_t msg; |
1055 | 1055 | mu_header_t hdr; | |
1056 | |||
1056 | mu_iterator_current (itr, (void **)&uidl); | 1057 | mu_iterator_current (itr, (void **)&uidl); |
1057 | 1058 | ||
1058 | if ((rc = mu_mailbox_get_message (source, uidl->msgno, &msg)) != 0) | 1059 | if ((rc = mu_mailbox_get_message (source, uidl->msgno, &msg)) != 0) |
@@ -1062,6 +1063,40 @@ main (int argc, char **argv) | |||
1062 | get_err_count++; | 1063 | get_err_count++; |
1063 | continue; | 1064 | continue; |
1064 | } | 1065 | } |
1066 | |||
1067 | /* Check if the downloaded message has X-UIDL header. If not, | ||
1068 | add one. This check should disappear one mailutils implements | ||
1069 | alternative storage for mailbox meta-data. */ | ||
1070 | if ((rc = mu_message_get_header (msg, &hdr))) | ||
1071 | { | ||
1072 | mu_error (_("%lu: cannot get header: %s"), | ||
1073 | (unsigned long) uidl->msgno, mu_strerror (rc)); | ||
1074 | } | ||
1075 | else | ||
1076 | { | ||
1077 | char const *suidl = NULL; | ||
1078 | |||
1079 | if ((rc = mu_header_sget_value (hdr, MU_HEADER_X_UIDL, &suidl))) | ||
1080 | { | ||
1081 | if (rc != MU_ERR_NOENT) | ||
1082 | mu_error (_("%lu: cannot get %s: %s"), | ||
1083 | (unsigned long) uidl->msgno, MU_HEADER_X_UIDL, | ||
1084 | mu_strerror (rc)); | ||
1085 | } | ||
1086 | else if (strcmp (suidl, uidl->uidl)) | ||
1087 | { | ||
1088 | mu_error (_("%lu: stored and reported UIDL differ; fixing"), | ||
1089 | (unsigned long) uidl->msgno); | ||
1090 | suidl = NULL; | ||
1091 | } | ||
1092 | |||
1093 | if ((rc = mu_header_set_value (hdr, MU_HEADER_X_UIDL, | ||
1094 | uidl->uidl, 1))) | ||
1095 | { | ||
1096 | mu_error (_("%lu: cannot set header: %s"), | ||
1097 | (unsigned long) uidl->msgno, mu_strerror (rc)); | ||
1098 | } | ||
1099 | } | ||
1065 | progress_mark (itr); | 1100 | progress_mark (itr); |
1066 | if (movemail (dest, msg, uidl->msgno)) | 1101 | if (movemail (dest, msg, uidl->msgno)) |
1067 | break; | 1102 | break; |