[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-file.c, 1.1, 1.2 mbox-sync.c, 1.26, 1.27

cras at procontrol.fi cras at procontrol.fi
Wed Jun 16 09:09:33 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv7601/lib-storage/index/mbox

Modified Files:
	mbox-file.c mbox-sync.c 
Log Message:
EXAMINE/STATUS should also update metadata changes, they don't really open
the mbox as readonly.



Index: mbox-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-file.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mbox-file.c	6 May 2004 01:22:25 -0000	1.1
+++ mbox-file.c	16 Jun 2004 06:09:31 -0000	1.2
@@ -15,7 +15,12 @@
 
 	i_assert(ibox->mbox_fd == -1);
 
-	fd = open(ibox->path, ibox->readonly ? O_RDONLY : O_RDWR);
+	fd = open(ibox->path, ibox->mbox_readonly ? O_RDONLY : O_RDWR);
+	if (fd == -1 && errno == EACCES && !ibox->mbox_readonly) {
+                ibox->mbox_readonly = TRUE;
+		fd = open(ibox->path, O_RDONLY);
+	}
+
 	if (fd == -1) {
 		mbox_set_syscall_error(ibox, "open()");
 		return -1;

Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mbox-sync.c	16 Jun 2004 05:54:43 -0000	1.26
+++ mbox-sync.c	16 Jun 2004 06:09:31 -0000	1.27
@@ -69,6 +69,8 @@
 	struct stat old_st, st;
 	uoff_t old_from_offset = 0, old_offset = 0;
 
+	i_assert(lock_type != F_WRLCK || !ibox->mbox_readonly);
+
 	if (sync_ctx->lock_id != 0) {
 		if (fstat(sync_ctx->fd, &old_st) < 0) {
 			mbox_set_syscall_error(ibox, "stat()");
@@ -232,7 +234,7 @@
 
 	*sync_expunge_r = FALSE;
 
-	if (sync_ctx->ibox->readonly || sync_ctx->index_sync_ctx == NULL)
+	if (sync_ctx->ibox->mbox_readonly || sync_ctx->index_sync_ctx == NULL)
 		return 0;
 
 	mbox_sync_buffer_delete_old(sync_ctx->syncs, uid);
@@ -506,7 +508,7 @@
 	if (sync_ctx->first_uid == 0)
 		sync_ctx->first_uid = mail_ctx->mail.uid;
 
-	if (sync_ctx->ibox->readonly)
+	if (sync_ctx->ibox->mbox_readonly)
 		return 0;
 
 	if (sync_ctx->expunged_space > 0 && sync_ctx->need_space_seq == 0) {
@@ -1055,7 +1057,8 @@
 	if (mail_index_sync_end(index_sync_ctx) < 0)
 		ret = -1;
 
-	if (sync_ctx.base_uid_last != sync_ctx.next_uid-1 && ret == 0) {
+	if (sync_ctx.base_uid_last != sync_ctx.next_uid-1 && ret == 0 &&
+	    !ibox->mbox_readonly) {
 		/* rewrite X-IMAPbase header. do it after mail_index_sync_end()
 		   so previous transactions have been committed. */
 		/* FIXME: ugly .. */



More information about the dovecot-cvs mailing list