comparison src/lib-storage/index/maildir/maildir-sync.c @ 9067:e7792f4509e6 HEAD

Maildir: Make sure messages are removed from index if they are deleted externally from new/. The problem happened when a message in new/ was indexed, deleted externally and the mailbox was again opened as read-only. This caused a partial sync in new/ directory, which didn't notice that the files were gone.
author Timo Sirainen <tss@iki.fi>
date Wed, 20 May 2009 17:47:49 -0400
parents 0bb192fe0abd
children 4e74f4651f5b
comparison
equal deleted inserted replaced
9066:a31fb9b7179a 9067:e7792f4509e6
641 maildir_uidlist_set_next_uid(mbox->uidlist, 641 maildir_uidlist_set_next_uid(mbox->uidlist,
642 hdr->next_uid, FALSE); 642 hdr->next_uid, FALSE);
643 } 643 }
644 } 644 }
645 645
646 static bool move_recent_messages(struct maildir_sync_context *ctx) 646 static bool have_recent_messages(struct maildir_sync_context *ctx)
647 { 647 {
648 const struct mail_index_header *hdr; 648 const struct mail_index_header *hdr;
649
650 if (ctx->mbox->ibox.keep_recent)
651 return FALSE;
652 649
653 (void)maildir_uidlist_refresh(ctx->mbox->uidlist); 650 (void)maildir_uidlist_refresh(ctx->mbox->uidlist);
654 651
655 /* if there are files in new/, we'll need to move them. we'll check 652 /* if there are files in new/, we'll need to move them. we'll check
656 this by checking if we have any recent messages */ 653 this by checking if we have any recent messages */
671 return -1; 668 return -1;
672 669
673 if (*new_changed_r || *cur_changed_r) 670 if (*new_changed_r || *cur_changed_r)
674 return 1; 671 return 1;
675 672
676 if (move_recent_messages(ctx)) { 673 if (have_recent_messages(ctx)) {
677 *new_changed_r = TRUE; 674 if (!ctx->mbox->ibox.keep_recent) {
678 return 1; 675 *new_changed_r = TRUE;
676 return 1;
677 } else if (*new_changed_r) {
678 /* we have some recent messages and new/ has changed.
679 if messages had been externally deleted from new/,
680 we need to get them out of index. this requires that
681 we make sure they weren't just moved to cur/. */
682 *cur_changed_r = TRUE;
683 return 1;
684 }
679 } 685 }
680 686
681 if (!ctx->mbox->ibox.keep_recent) 687 if (!ctx->mbox->ibox.keep_recent)
682 flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT; 688 flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
683 689