From d987b48e12054e6eba632387a8639aaab07735cb Mon Sep 17 00:00:00 2001 From: Not Zed Date: Fri, 2 Aug 2002 05:13:38 +0000 Subject: revert jeff's patch below, and do it slightly differently, and stop the 2002-08-02 Not Zed * 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 * 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. svn path=/trunk/; revision=17685 --- camel/providers/local/camel-maildir-summary.c | 63 ++++++++++++++++----------- 1 file changed, 37 insertions(+), 26 deletions(-) (limited to 'camel/providers') 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); -- cgit v1.2.3