Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib-storage/index/maildir/maildir-sync.c @ 7066:048325df1ec4 HEAD
If MAILBOX_SYNC_FLAG_FULL_READ flag is set (SELECT and CHECK IMAP commands),
make sure we refresh maildirs with delayed syncs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 29 Dec 2007 19:10:35 +0200 |
parents | e74a1d1dca07 |
children | 7ed926ed7aa4 |
comparison
equal
deleted
inserted
replaced
7065:04e048fcd6d7 | 7066:048325df1ec4 |
---|---|
534 else | 534 else |
535 memcpy(&mbox->maildir_hdr, data, sizeof(mbox->maildir_hdr)); | 535 memcpy(&mbox->maildir_hdr, data, sizeof(mbox->maildir_hdr)); |
536 return 0; | 536 return 0; |
537 } | 537 } |
538 | 538 |
539 static int maildir_sync_quick_check(struct maildir_mailbox *mbox, | 539 static int maildir_sync_quick_check(struct maildir_mailbox *mbox, bool undirty, |
540 const char *new_dir, const char *cur_dir, | 540 const char *new_dir, const char *cur_dir, |
541 bool *new_changed_r, bool *cur_changed_r) | 541 bool *new_changed_r, bool *cur_changed_r) |
542 { | 542 { |
543 #ifdef HAVE_STAT_TV_NSEC | 543 #ifdef HAVE_STAT_TV_NSEC |
544 # define DIR_NSECS_CHANGED(st, hdr, name) \ | 544 # define DIR_NSECS_CHANGED(st, hdr, name) \ |
548 #endif | 548 #endif |
549 | 549 |
550 #define DIR_DELAYED_REFRESH(hdr, name) \ | 550 #define DIR_DELAYED_REFRESH(hdr, name) \ |
551 ((hdr)->name ## _check_time <= \ | 551 ((hdr)->name ## _check_time <= \ |
552 (hdr)->name ## _mtime + MAILDIR_SYNC_SECS && \ | 552 (hdr)->name ## _mtime + MAILDIR_SYNC_SECS && \ |
553 (time_t)(hdr)->name ## _check_time < ioloop_time - MAILDIR_SYNC_SECS) | 553 (undirty || \ |
554 (time_t)(hdr)->name ## _check_time < ioloop_time - MAILDIR_SYNC_SECS)) | |
554 | 555 |
555 #define DIR_MTIME_CHANGED(st, hdr, name) \ | 556 #define DIR_MTIME_CHANGED(st, hdr, name) \ |
556 ((st).st_mtime != (time_t)(hdr)->name ## _mtime || \ | 557 ((st).st_mtime != (time_t)(hdr)->name ## _mtime || \ |
557 DIR_NSECS_CHANGED(st, hdr, name)) | 558 DIR_NSECS_CHANGED(st, hdr, name)) |
558 | 559 |
658 | 659 |
659 static int maildir_sync_get_changes(struct maildir_sync_context *ctx, | 660 static int maildir_sync_get_changes(struct maildir_sync_context *ctx, |
660 bool *new_changed_r, bool *cur_changed_r) | 661 bool *new_changed_r, bool *cur_changed_r) |
661 { | 662 { |
662 enum mail_index_sync_flags flags = 0; | 663 enum mail_index_sync_flags flags = 0; |
663 | 664 bool undirty = (ctx->flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0; |
664 if (maildir_sync_quick_check(ctx->mbox, ctx->new_dir, ctx->cur_dir, | 665 |
666 if (maildir_sync_quick_check(ctx->mbox, undirty, | |
667 ctx->new_dir, ctx->cur_dir, | |
665 new_changed_r, cur_changed_r) < 0) | 668 new_changed_r, cur_changed_r) < 0) |
666 return -1; | 669 return -1; |
667 | 670 |
668 if (*new_changed_r || *cur_changed_r) | 671 if (*new_changed_r || *cur_changed_r) |
669 return 1; | 672 return 1; |
901 const char *new_dir, *cur_dir; | 904 const char *new_dir, *cur_dir; |
902 | 905 |
903 new_dir = t_strconcat(mbox->path, "/new", NULL); | 906 new_dir = t_strconcat(mbox->path, "/new", NULL); |
904 cur_dir = t_strconcat(mbox->path, "/cur", NULL); | 907 cur_dir = t_strconcat(mbox->path, "/cur", NULL); |
905 | 908 |
906 ret = maildir_sync_quick_check(mbox, new_dir, cur_dir, | 909 ret = maildir_sync_quick_check(mbox, FALSE, new_dir, cur_dir, |
907 &new_changed, &cur_changed); | 910 &new_changed, &cur_changed); |
908 } T_FRAME_END; | 911 } T_FRAME_END; |
909 return ret < 0 ? -1 : (!new_changed && !cur_changed); | 912 return ret < 0 ? -1 : (!new_changed && !cur_changed); |
910 } | 913 } |