# HG changeset patch # User Timo Sirainen # Date 1203968338 -7200 # Node ID db65d921b0e15b1ba919af9375ac8dea4608c9aa # Parent 697000a67c420c3626ce87a94274af570038aba5 Check and update sync_last_check in one common function. diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/cydir/cydir-sync.c --- a/src/lib-storage/index/cydir/cydir-sync.c Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/cydir/cydir-sync.c Mon Feb 25 21:38:58 2008 +0200 @@ -179,9 +179,7 @@ if (!box->opened) index_storage_mailbox_open(&mbox->ibox); - if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 || - mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= - ioloop_time) + if (index_mailbox_want_full_sync(&mbox->ibox, flags)) ret = cydir_sync(mbox); return index_mailbox_sync_init(box, flags, ret < 0); diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/dbox/dbox-sync.c --- a/src/lib-storage/index/dbox/dbox-sync.c Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/dbox/dbox-sync.c Mon Feb 25 21:38:58 2008 +0200 @@ -396,9 +396,7 @@ if (!box->opened) index_storage_mailbox_open(&mbox->ibox); - if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 || - mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= - ioloop_time) + if (index_mailbox_want_full_sync(&mbox->ibox, flags)) ret = dbox_sync(mbox, FALSE); return index_mailbox_sync_init(box, flags, ret < 0); diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/index-storage.h Mon Feb 25 21:38:58 2008 +0200 @@ -126,6 +126,8 @@ const char *path); void index_mailbox_check_remove_all(struct index_mailbox *ibox); +bool index_mailbox_want_full_sync(struct index_mailbox *ibox, + enum mailbox_sync_flags flags); struct mailbox_sync_context * index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags, bool failed); diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/index-sync.c Mon Feb 25 21:38:58 2008 +0200 @@ -2,6 +2,7 @@ #include "lib.h" #include "seq-range-array.h" +#include "ioloop.h" #include "array.h" #include "buffer.h" #include "index-storage.h" @@ -19,6 +20,17 @@ bool failed; }; +bool index_mailbox_want_full_sync(struct index_mailbox *ibox, + enum mailbox_sync_flags flags) +{ + if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 && + ioloop_time < ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL) + return FALSE; + + ibox->sync_last_check = ioloop_time; + return TRUE; +} + void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid) { if (uid <= ibox->recent_flags_prev_uid) { diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 21:38:58 2008 +0200 @@ -871,11 +871,7 @@ if (!box->opened) index_storage_mailbox_open(&mbox->ibox); - if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 || - mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= - ioloop_time) { - mbox->ibox.sync_last_check = ioloop_time; - + if (index_mailbox_want_full_sync(&mbox->ibox, flags)) { T_BEGIN { ctx = maildir_sync_context_new(mbox, flags); ret = maildir_sync_context(ctx, FALSE, NULL, diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Mon Feb 25 21:37:45 2008 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Mon Feb 25 21:38:58 2008 +0200 @@ -1555,8 +1555,6 @@ ((flags & MBOX_SYNC_REWRITE) == 0 && getenv("MBOX_LAZY_WRITES") != NULL); - mbox->ibox.sync_last_check = ioloop_time; - if (!mbox->mbox_do_dirty_syncs) flags |= MBOX_SYNC_UNDIRTY; @@ -1812,9 +1810,7 @@ if (!box->opened) index_storage_mailbox_open(&mbox->ibox); - if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 || - mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= - ioloop_time) { + if (index_mailbox_want_full_sync(&mbox->ibox, flags)) { if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 && !mbox->mbox_very_dirty_syncs) mbox_sync_flags |= MBOX_SYNC_UNDIRTY;