changeset 6601:835daa872b0a HEAD

Fixes to handling maildir files.
author Timo Sirainen <tss@iki.fi>
date Sun, 21 Oct 2007 19:14:56 +0300
parents 416d9ee66047
children 3660e9cc06d2
files src/lib-storage/index/dbox/dbox-file.c src/lib-storage/index/dbox/dbox-index.c src/lib-storage/index/dbox/dbox-sync-file.c src/lib-storage/index/dbox/dbox-sync.c
diffstat 4 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-file.c	Sun Oct 21 18:58:00 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-file.c	Sun Oct 21 19:14:56 2007 +0300
@@ -942,6 +942,8 @@
 		/* nothing to write */
 		return 1;
 	}
+	if (file->maildir_file)
+		return 0;
 
 	offset = file->metadata_read_offset +
 		sizeof(struct dbox_metadata_header);
--- a/src/lib-storage/index/dbox/dbox-index.c	Sun Oct 21 18:58:00 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-index.c	Sun Oct 21 19:14:56 2007 +0300
@@ -91,11 +91,14 @@
 	char *p;
 	unsigned long uid;
 
+	if (*line++ != ' ')
+		return -1;
+
 	uid = strtoul(line, &p, 10);
 	if (*p++ != ' ' || *p == '\0' || uid == 0 || uid >= (uint32_t)-1)
 		return -1;
 
-	rec->data = p_strdup(index->record_data_pool, p);
+	rec->data = p_strdup(index->record_data_pool, line);
 	return 0;
 }
 
@@ -324,6 +327,11 @@
 	if ((file_id & DBOX_FILE_ID_FLAG_UID) != 0)
 		return NULL;
 
+	if (index->fd == -1) {
+		if (dbox_index_refresh(index) < 0)
+			return NULL;
+	}
+
 	records = array_get_modifiable(&index->records, &count);
 	return bsearch(&file_id, records, count, sizeof(*records),
 		       dbox_index_record_cmp);
--- a/src/lib-storage/index/dbox/dbox-sync-file.c	Sun Oct 21 18:58:00 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-sync-file.c	Sun Oct 21 19:14:56 2007 +0300
@@ -193,8 +193,11 @@
 	dbox_sync_update_metadata(ctx, file, entry, seq);
 	ret = dbox_file_metadata_write(file);
 	if (ret <= 0) {
-		/* FIXME: handle ret=0 case by splitting the file */
-		return ret;
+		if (ret < 0)
+			return -1;
+		/* FIXME: handle ret=0 case by splitting the file
+		   (or converting maildir file to dbox) */
+		return 1;
 	}
 
 	mail_index_update_flags(ctx->trans, seq, MODIFY_REMOVE,
--- a/src/lib-storage/index/dbox/dbox-sync.c	Sun Oct 21 18:58:00 2007 +0300
+++ b/src/lib-storage/index/dbox/dbox-sync.c	Sun Oct 21 19:14:56 2007 +0300
@@ -233,8 +233,8 @@
 	const void *data;
 	size_t data_size;
 
-	if (mbox->last_interactive_change <
-	    ioloop_time - DBOX_FLUSH_SECS_INTERACTIVE)
+	/*if (mbox->last_interactive_change <
+	    ioloop_time - DBOX_FLUSH_SECS_INTERACTIVE)*/
 		return TRUE;
 
 	mail_index_get_header_ext(mbox->ibox.view, mbox->dbox_hdr_ext_id,