aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-folder-summary.c70
-rw-r--r--camel/providers/local/camel-maildir-summary.c63
3 files changed, 79 insertions, 68 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index a100de7cd7..f5132f20cd 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2002-08-02 Not Zed <NotZed@Ximian.com>
+
+ * camel-folder-summary.c (message_info_load): revert jeff's patch
+ below, and do it slightly differently, and stop the auto-reformatting
+ bullshit.
+
+2002-08-02 Not Zed <NotZed@Ximian.com>
+
+ * providers/local/camel-maildir-summary.c (message_info_new): If
+ we get a duplicate, just re-use the old info.
+ (remove_summary): Add any removed to a change list.
+ (maildir_summary_check): If we find new ones in 'cur' track them
+ in the change list. Removed FIXME about it. For #18348.
+
2002-08-01 Jeffrey Stedfast <fejj@ximian.com>
* camel-folder-summary.c (message_info_load): Do more error
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 82571e7632..ebef730c70 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1693,66 +1693,52 @@ message_info_load(CamelFolderSummary *s, FILE *in)
#endif
mi->content = NULL;
-
- /* decode the message-id */
- if (camel_file_util_decode_fixed_int32 (in, &mi->message_id.id.part.hi) == -1)
- goto error;
- if (camel_file_util_decode_fixed_int32 (in, &mi->message_id.id.part.lo) == -1)
- goto error;
-
- /* decode the references count */
- if (camel_file_util_decode_uint32 (in, &count) == -1 || count > 500)
+
+ camel_file_util_decode_fixed_int32(in, &mi->message_id.id.part.hi);
+ camel_file_util_decode_fixed_int32(in, &mi->message_id.id.part.lo);
+
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
-
+
if (count > 0) {
- /* decode the references */
mi->references = g_malloc(sizeof(*mi->references) + ((count-1) * sizeof(mi->references->references[0])));
mi->references->size = count;
- for (i = 0; i < count; i++) {
- if (camel_file_util_decode_fixed_int32 (in, &mi->references->references[i].id.part.hi) == -1)
- goto error;
- if (camel_file_util_decode_fixed_int32 (in, &mi->references->references[i].id.part.lo) == -1)
- goto error;
+ for (i=0;i<count;i++) {
+ camel_file_util_decode_fixed_int32(in, &mi->references->references[i].id.part.hi);
+ camel_file_util_decode_fixed_int32(in, &mi->references->references[i].id.part.lo);
}
}
-
- if (camel_file_util_decode_uint32 (in, &count) == -1 || count > 500)
+
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
-
- /* decode the user-flags */
- for (i = 0; i < count; i++) {
+
+ for (i=0;i<count;i++) {
char *name;
-
- if (camel_file_util_decode_string (in, &name) == -1)
+ if (camel_file_util_decode_string(in, &name) == -1 || name == NULL)
goto error;
-
- camel_flag_set (&mi->user_flags, name, TRUE);
- g_free (name);
+ camel_flag_set(&mi->user_flags, name, TRUE);
+ g_free(name);
}
-
- if (camel_file_util_decode_uint32 (in, &count) == -1 || count > 500)
+
+ if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
-
- /* decode the user-tags */
- for (i = 0; i < count; i++) {
+
+ for (i=0;i<count;i++) {
char *name, *value;
-
- if (camel_file_util_decode_string (in, &name) == -1)
- goto error;
- if (camel_file_util_decode_string (in, &value) == -1)
+ if (camel_file_util_decode_string(in, &name) == -1 || name == NULL
+ || camel_file_util_decode_string(in, &value) == -1)
goto error;
-
- camel_tag_set (&mi->user_tags, name, value);
- g_free (name);
- g_free (value);
+ camel_tag_set(&mi->user_tags, name, value);
+ g_free(name);
+ g_free(value);
}
-
+
if (!ferror(in))
return mi;
-
+
error:
camel_folder_summary_info_free(s, mi);
-
+
return NULL;
}
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index b0bd172257..ae3b81438b 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -258,7 +258,7 @@ static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMe
static CamelMessageInfo *message_info_new(CamelFolderSummary * s, struct _header_raw *h)
{
- CamelMessageInfo *mi;
+ CamelMessageInfo *mi, *info;
CamelMaildirSummary *mds = (CamelMaildirSummary *)s;
CamelMaildirMessageInfo *mdi;
const char *uid;
@@ -272,6 +272,14 @@ static CamelMessageInfo *message_info_new(CamelFolderSummary * s, struct _header
if (uid==NULL || uid[0] == 0)
camel_message_info_set_uid(mi, camel_folder_summary_next_uid_string(s));
+ /* handle 'duplicates' */
+ info = camel_folder_summary_uid(s, uid);
+ if (info) {
+ d(printf("already seen uid '%s', just summarising instead\n", uid));
+ camel_folder_summary_info_free(s, mi);
+ mdi = (CamelMaildirMessageInfo *)mi = info;
+ }
+
/* with maildir we know the real received date, from the filename */
mi->date_received = strtoul(camel_message_info_uid(mi), NULL, 10);
@@ -475,14 +483,21 @@ static int camel_maildir_summary_add(CamelLocalSummary *cls, const char *name, i
return 0;
}
+struct _remove_data {
+ CamelLocalSummary *cls;
+ CamelFolderChangeInfo *changes;
+};
+
static void
-remove_summary(char *key, CamelMessageInfo *info, CamelLocalSummary *cls)
+remove_summary(char *key, CamelMessageInfo *info, struct _remove_data *rd)
{
d(printf("removing message %s from summary\n", key));
- if (cls->index)
- camel_index_delete_name(cls->index, camel_message_info_uid(info));
- camel_folder_summary_remove((CamelFolderSummary *)cls, info);
- camel_folder_summary_info_free((CamelFolderSummary *)cls, info);
+ if (rd->cls->index)
+ camel_index_delete_name(rd->cls->index, camel_message_info_uid(info));
+ if (rd->changes)
+ camel_folder_change_info_remove_uid(rd->changes, key);
+ camel_folder_summary_remove((CamelFolderSummary *)rd->cls, info);
+ camel_folder_summary_info_free((CamelFolderSummary *)rd->cls, info);
}
static int
@@ -514,12 +529,11 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
int forceindex;
char *new, *cur;
char *uid;
+ struct _remove_data rd = { cls, changes };
new = g_strdup_printf("%s/new", cls->folder_path);
cur = g_strdup_printf("%s/cur", cls->folder_path);
- /* FIXME: Handle changeinfo */
-
d(printf("checking summary ...\n"));
camel_operation_start(NULL, _("Checking folder consistency"));
@@ -570,28 +584,25 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
uid = g_strndup(d->d_name, uid-d->d_name);
else
uid = g_strdup(d->d_name);
+
+ info = g_hash_table_lookup(left, uid);
+ if (info) {
+ camel_folder_summary_info_free((CamelFolderSummary *)cls, info);
+ g_hash_table_remove(left, uid);
+ }
info = camel_folder_summary_uid((CamelFolderSummary *)cls, uid);
- if (info == NULL || (cls->index && (!camel_index_has_name(cls->index, uid)))) {
- /* need to add this file to the summary */
- if (info != NULL) {
- CamelMessageInfo *old = g_hash_table_lookup(left, camel_message_info_uid(info));
- if (old) {
- g_hash_table_remove(left, uid);
- camel_folder_summary_info_free((CamelFolderSummary *)cls, old);
- }
- camel_folder_summary_remove((CamelFolderSummary *)cls, info);
- camel_folder_summary_info_free((CamelFolderSummary *)cls, info);
- }
- camel_maildir_summary_add(cls, d->d_name, forceindex);
+ if (info == NULL) {
+ /* must be a message incorporated by another client, this is not a 'recent' uid */
+ if (camel_maildir_summary_add(cls, d->d_name, forceindex) == 0)
+ if (changes)
+ camel_folder_change_info_add_uid(changes, uid);
} else {
const char *filename;
- CamelMessageInfo *old;
- old = g_hash_table_lookup(left, camel_message_info_uid(info));
- if (old) {
- camel_folder_summary_info_free((CamelFolderSummary *)cls, old);
- g_hash_table_remove(left, camel_message_info_uid(info));
+ if (cls->index && (!camel_index_has_name(cls->index, uid))) {
+ /* message_info_new will handle duplicates */
+ camel_maildir_summary_add(cls, d->d_name, forceindex);
}
mdi = (CamelMaildirMessageInfo *)info;
@@ -621,7 +632,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca
g_free(uid);
}
closedir(dir);
- g_hash_table_foreach(left, (GHFunc)remove_summary, cls);
+ g_hash_table_foreach(left, (GHFunc)remove_summary, &rd);
g_hash_table_destroy(left);
camel_operation_end(NULL);