changeset 2893:fd431866c674 HEAD

mail_index_refresh() isn't public anymore, mail_index_view_open_locked() works better for the purpose.
author Timo Sirainen <tss@iki.fi>
date Wed, 24 Nov 2004 22:40:39 +0200
parents 62d53b49110d
children e7d6ae64fd68
files src/lib-index/mail-index-private.h src/lib-index/mail-index.h src/lib-storage/index/maildir/maildir-sync.c
diffstat 3 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h	Wed Nov 24 20:39:57 2004 +0200
+++ b/src/lib-index/mail-index-private.h	Wed Nov 24 22:40:39 2004 +0200
@@ -165,6 +165,9 @@
 int mail_index_lock_fd(struct mail_index *index, int fd, int lock_type,
 		       unsigned int timeout_secs);
 
+/* Reopen index file if it has changed. */
+int mail_index_refresh(struct mail_index *index);
+
 /* Map index file to memory, replacing the previous mapping for index.
    Returns 1 = ok, 0 = corrupted, -1 = error. If index needs fscking, it
    returns 1 but sets index->fsck = TRUE. */
--- a/src/lib-index/mail-index.h	Wed Nov 24 20:39:57 2004 +0200
+++ b/src/lib-index/mail-index.h	Wed Nov 24 22:40:39 2004 +0200
@@ -149,9 +149,6 @@
 		    enum mail_index_lock_method lock_method);
 void mail_index_close(struct mail_index *index);
 
-/* Force checking if index can be refreshed. */
-int mail_index_refresh(struct mail_index *index);
-
 struct mail_cache *mail_index_get_cache(struct mail_index *index);
 
 /* View can be used to look into index. Sequence numbers inside view change
--- a/src/lib-storage/index/maildir/maildir-sync.c	Wed Nov 24 20:39:57 2004 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Wed Nov 24 22:40:39 2004 +0200
@@ -532,21 +532,19 @@
 	}
 	cur_mtime = st.st_mtime;
 
-	if (ibox->dirty_cur_time == 0) {
-		/* cur stamp is kept in index, we don't have to sync if
-		   someone else has done it and updated the index. make sure
-		   we have a fresh index with latest sync_stamp. */
+	/* cur stamp is kept in index, we don't have to sync if
+	   someone else has done it and updated the index. */
+	ibox->last_cur_mtime = mail_index_get_header(ibox->view)->sync_stamp;
+	if (ibox->dirty_cur_time == 0 && cur_mtime != ibox->last_cur_mtime) {
+		/* check if the index has been updated.. */
 		struct mail_index_view *view;
-		const struct mail_index_header *hdr;
 
-		if (mail_index_refresh(ibox->index) < 0) {
+		if (mail_index_view_open_locked(ibox->index, &view) < 0) {
 			mail_storage_set_index_error(ibox);
 			return -1;
 		}
 
-		view = mail_index_view_open(ibox->index);
-		hdr = mail_index_get_header(view);
-		ibox->last_cur_mtime = hdr->sync_stamp;
+		ibox->last_cur_mtime = mail_index_get_header(view)->sync_stamp;
 		mail_index_view_close(view);
 	}