Bugfix.
Imap4d would fail to select a nonexistent maildir INBOX, because the mu_mailbox_uidvalidity would return MU_ERR_NOENT. * libmailutils/base/amd.c (_amd_scan0): Recompute uidvalidity if the mailbox is empty.
Showing
1 changed file
with
7 additions
and
9 deletions
... | @@ -695,19 +695,17 @@ static int | ... | @@ -695,19 +695,17 @@ static int |
695 | _amd_scan0 (struct _amd_data *amd, size_t msgno, size_t *pcount, | 695 | _amd_scan0 (struct _amd_data *amd, size_t msgno, size_t *pcount, |
696 | int do_notify) | 696 | int do_notify) |
697 | { | 697 | { |
698 | unsigned long uidval; | ||
698 | int status = amd->scan0 (amd->mailbox, msgno, pcount, do_notify); | 699 | int status = amd->scan0 (amd->mailbox, msgno, pcount, do_notify); |
699 | if (status != 0) | 700 | if (status != 0) |
700 | return status; | 701 | return status; |
701 | /* Reset the uidvalidity. */ | 702 | /* Reset the uidvalidity. */ |
702 | if (amd->msg_count > 0) | 703 | if (amd->msg_count == 0 || |
704 | _amd_prop_fetch_ulong (amd, _MU_AMD_PROP_UIDVALIDITY, &uidval) || | ||
705 | !uidval) | ||
703 | { | 706 | { |
704 | unsigned long uidval; | 707 | uidval = (unsigned long)time (NULL); |
705 | if (_amd_prop_fetch_ulong (amd, _MU_AMD_PROP_UIDVALIDITY, &uidval) || | 708 | _amd_prop_store_off (amd, _MU_AMD_PROP_UIDVALIDITY, uidval); |
706 | !uidval) | ||
707 | { | ||
708 | uidval = (unsigned long)time (NULL); | ||
709 | _amd_prop_store_off (amd, _MU_AMD_PROP_UIDVALIDITY, uidval); | ||
710 | } | ||
711 | } | 709 | } |
712 | return 0; | 710 | return 0; |
713 | } | 711 | } |
... | @@ -1502,7 +1500,7 @@ amd_uidvalidity (mu_mailbox_t mailbox, unsigned long *puidvalidity) | ... | @@ -1502,7 +1500,7 @@ amd_uidvalidity (mu_mailbox_t mailbox, unsigned long *puidvalidity) |
1502 | int status = amd_messages_count (mailbox, NULL); | 1500 | int status = amd_messages_count (mailbox, NULL); |
1503 | if (status != 0) | 1501 | if (status != 0) |
1504 | return status; | 1502 | return status; |
1505 | /* If we did not start a scanning yet do it now. */ | 1503 | /* If we did not start scanning yet do it now. */ |
1506 | if (amd->msg_count == 0) | 1504 | if (amd->msg_count == 0) |
1507 | { | 1505 | { |
1508 | status = _amd_scan0 (amd, 1, NULL, 0); | 1506 | status = _amd_scan0 (amd, 1, NULL, 0); | ... | ... |
-
Please register or sign in to post a comment