evolution-data-server/0004-evo-I-982-Message-contains-search-broken-in-3.36.3.patch

82 lines
2.6 KiB
Diff

From 70c6f2e2b204714ecb4d920eb0b10d8f54dc5e7d Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Mon, 15 Jun 2020 15:15:58 +0200
Subject: [PATCH 4/4] evo-I#982 - 'Message contains'-search broken in 3.36.3 ][
Fix incorrect result, where the first call, which did the server-side
call, could return currently processed message as matching, even when
it did not match the search criteria.
Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/982
---
.../providers/imapx/camel-imapx-search.c | 38 +++++++++----------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/src/camel/providers/imapx/camel-imapx-search.c b/src/camel/providers/imapx/camel-imapx-search.c
index 7c62443b8..2a34b389c 100644
--- a/src/camel/providers/imapx/camel-imapx-search.c
+++ b/src/camel/providers/imapx/camel-imapx-search.c
@@ -244,18 +244,32 @@ imapx_search_process_criteria (CamelSExp *sexp,
}
}
+ if (!cached_results) {
+ cached_results = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) camel_pstring_free, NULL);
+
+ if (uids) {
+ guint ii;
+
+ for (ii = 0; ii < uids->len; ii++) {
+ g_hash_table_insert (cached_results, (gpointer) camel_pstring_strdup (uids->pdata[ii]), NULL);
+ }
+ }
+
+ g_hash_table_insert (imapx_search->priv->cached_results, criteria_desc, cached_results);
+ } else {
+ g_free (criteria_desc);
+ }
+
info = camel_folder_search_get_current_message_info (search);
if (info) {
result = camel_sexp_result_new (sexp, CAMEL_SEXP_RES_BOOL);
- result->value.boolean = cached_results ? g_hash_table_contains (cached_results, camel_message_info_get_uid (info)) : (uids && uids->len > 0);
+ result->value.boolean = g_hash_table_contains (cached_results, camel_message_info_get_uid (info));
} else {
- if (cached_results) {
+ if (!uids) {
GHashTableIter iter;
gpointer key;
- g_warn_if_fail (uids == NULL);
-
uids = g_ptr_array_sized_new (g_hash_table_size (cached_results));
g_hash_table_iter_init (&iter, cached_results);
@@ -269,22 +283,6 @@ imapx_search_process_criteria (CamelSExp *sexp,
result->value.ptrarray = g_ptr_array_ref (uids);
}
- if (!cached_results) {
- cached_results = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) camel_pstring_free, NULL);
-
- if (uids) {
- guint ii;
-
- for (ii = 0; ii < uids->len; ii++) {
- g_hash_table_insert (cached_results, (gpointer) camel_pstring_strdup (uids->pdata[ii]), NULL);
- }
- }
-
- g_hash_table_insert (imapx_search->priv->cached_results, criteria_desc, cached_results);
- } else {
- g_free (criteria_desc);
- }
-
if (uids)
g_ptr_array_unref (uids);
--
2.27.0