evolution-data-server r9678 - trunk/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9678 - trunk/camel
- Date: Thu, 16 Oct 2008 04:12:12 +0000 (UTC)
Author: sragavan
Date: Thu Oct 16 04:12:12 2008
New Revision: 9678
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9678&view=rev
Log:
2008-10-16 Srinivasa Ragavan <sragavan novell com>
** Fix for bug #556495
* camel/camel-db.c:
* camel/camel-db.h:
* camel/camel-vee-folder.c: When things don't match, remove them from
db and force a count.
Modified:
trunk/camel/ChangeLog
trunk/camel/camel-db.c
trunk/camel/camel-db.h
trunk/camel/camel-vee-folder.c
Modified: trunk/camel/camel-db.c
==============================================================================
--- trunk/camel/camel-db.c (original)
+++ trunk/camel/camel-db.c Thu Oct 16 04:12:12 2008
@@ -921,8 +921,8 @@
return ret;
}
-int
-camel_db_delete_uids (CamelDB *cdb, const char * folder_name, GSList *uids, CamelException *ex)
+static int
+cdb_delete_ids (CamelDB *cdb, const char * folder_name, GSList *uids, char *uid_prefix, const char *field, CamelException *ex)
{
char *tmp;
int ret;
@@ -930,14 +930,16 @@
GString *str = g_string_new ("DELETE FROM ");
GSList *iterator;
- tmp = sqlite3_mprintf ("%Q WHERE uid IN (", folder_name);
+ tmp = sqlite3_mprintf ("%Q WHERE %s IN (", folder_name, field);
g_string_append_printf (str, "%s ", tmp);
sqlite3_free (tmp);
iterator = uids;
while (iterator) {
- tmp = sqlite3_mprintf ("%Q", (char *) iterator->data);
+ char *foo = g_strdup_printf("%s%s", uid_prefix, (char *) iterator->data);
+ tmp = sqlite3_mprintf ("%Q", foo);
+ g_free(foo);
iterator = iterator->next;
if (first == TRUE) {
@@ -959,6 +961,18 @@
}
int
+camel_db_delete_uids (CamelDB *cdb, const char * folder_name, GSList *uids, CamelException *ex)
+{
+ return cdb_delete_ids (cdb, folder_name, uids, "", "uid", ex);
+}
+
+int
+camel_db_delete_vuids (CamelDB *cdb, const char * folder_name, char *hash, GSList *uids, CamelException *ex)
+{
+ return cdb_delete_ids (cdb, folder_name, uids, hash, "vuid", ex);
+}
+
+int
camel_db_clear_folder_summary (CamelDB *cdb, char *folder, CamelException *ex)
{
int ret;
Modified: trunk/camel/camel-db.h
==============================================================================
--- trunk/camel/camel-db.h (original)
+++ trunk/camel/camel-db.h Thu Oct 16 04:12:12 2008
@@ -121,6 +121,7 @@
int camel_db_delete_uid (CamelDB *cdb, const char *folder, const char *uid, CamelException *ex);
/*int camel_db_delete_uids (CamelDB *cdb, CamelException *ex, int nargs, ... );*/
int camel_db_delete_uids (CamelDB *cdb, const char* folder_name, GSList *uids, CamelException *ex);
+int camel_db_delete_vuids (CamelDB *cdb, const char* folder_name, char *shash, GSList *uids, CamelException *ex);
int camel_db_create_folders_table (CamelDB *cdb, CamelException *ex);
int camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex);
Modified: trunk/camel/camel-vee-folder.c
==============================================================================
--- trunk/camel/camel-vee-folder.c (original)
+++ trunk/camel/camel-vee-folder.c Thu Oct 16 04:12:12 2008
@@ -1061,7 +1061,8 @@
vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
{
GPtrArray *match, *all;
- GHashTable *allhash, *matchhash;
+ GHashTable *allhash, *matchhash, *fullhash;
+ GSList *del_list = NULL;
CamelFolder *f = source;
CamelFolder *folder = (CamelFolder *)vf;
int i, n, count, start, last;
@@ -1119,10 +1120,25 @@
g_hash_table_insert(matchhash, match->pdata[i], GINT_TO_POINTER (1));
allhash = g_hash_table_new(g_str_hash, g_str_equal);
+ fullhash = g_hash_table_new(g_str_hash, g_str_equal);
all = camel_folder_summary_array(f->summary);
- for (i=0;i<all->len;i++)
+ for (i=0;i<all->len;i++) {
if (g_hash_table_lookup(matchhash, all->pdata[i]) == NULL)
g_hash_table_insert(allhash, all->pdata[i], GINT_TO_POINTER (1));
+ g_hash_table_insert(fullhash, all->pdata[i], GINT_TO_POINTER (1));
+
+ }
+ count = match->len;
+ for (i=0; i<count; i++) {
+ if (!g_hash_table_lookup(fullhash, match->pdata[i])) {
+ g_hash_table_remove (matchhash, match->pdata[i]);
+ del_list = g_slist_prepend (del_list, match->pdata[i]); /* Free the original */
+ g_ptr_array_remove_index_fast (match, i);
+ i--;
+ count--;
+ continue;
+ }
+ }
if (folder_unmatched != NULL)
CAMEL_VEE_FOLDER_LOCK(folder_unmatched, summary_lock);
@@ -1221,9 +1237,19 @@
}
CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+
+ /* Del the unwanted things from the summary, we don't hold any locks now. */
+ if (del_list) {
+ camel_db_delete_vuids(folder->parent_store->cdb_w, folder->full_name, shash, del_list, NULL);
+ ((CamelVeeSummary *)folder->summary)->force_counts = TRUE;
+ g_slist_foreach (del_list, (GFunc) camel_pstring_free, NULL);
+ g_slist_free (del_list);
+ };
g_hash_table_destroy(matchhash);
g_hash_table_destroy(allhash);
+ g_hash_table_destroy(fullhash);
+
g_free(shash);
/* if expression not set, we only had a null list */
if (vf->expression == NULL || !rebuilded) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]