changeset 7291:db65d921b0e1 HEAD

Check and update sync_last_check in one common function.
author Timo Sirainen <tss@iki.fi>
date Mon, 25 Feb 2008 21:38:58 +0200
parents 697000a67c42
children d0520bb9177f
files src/lib-storage/index/cydir/cydir-sync.c src/lib-storage/index/dbox/dbox-sync.c src/lib-storage/index/index-storage.h src/lib-storage/index/index-sync.c src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/mbox/mbox-sync.c
diffstat 6 files changed, 18 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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);
--- 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);
--- 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) {
--- 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,
--- 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;