[evolution-data-server] Bug 787514 - [IMAPx] Overaggressive folder change saving after filtering
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 787514 - [IMAPx] Overaggressive folder change saving after filtering
- Date: Tue, 19 Sep 2017 16:08:30 +0000 (UTC)
commit dbd70b9f0462d6e8a8664535a36c353b15c52699
Author: Milan Crha <mcrha redhat com>
Date: Tue Sep 19 18:09:15 2017 +0200
Bug 787514 - [IMAPx] Overaggressive folder change saving after filtering
src/camel/camel-filter-driver.c | 46 +++++++++++++++++------
src/camel/providers/imapx/camel-imapx-server.c | 9 +++--
2 files changed, 39 insertions(+), 16 deletions(-)
---
diff --git a/src/camel/camel-filter-driver.c b/src/camel/camel-filter-driver.c
index abcd79e..8ae2cc6 100644
--- a/src/camel/camel-filter-driver.c
+++ b/src/camel/camel-filter-driver.c
@@ -123,7 +123,7 @@ struct _CamelFilterDriverPrivate {
static void camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, const gchar *desc,
...);
static CamelFolder *open_folder (CamelFilterDriver *d, const gchar *folder_url);
-static gint close_folders (CamelFilterDriver *d);
+static gint close_folders (CamelFilterDriver *d, GCancellable *cancellable);
static CamelSExpResult *do_delete (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv,
CamelFilterDriver *);
static CamelSExpResult *do_forward_to (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv,
CamelFilterDriver *);
@@ -216,7 +216,7 @@ filter_driver_finalize (GObject *object)
priv = CAMEL_FILTER_DRIVER_GET_PRIVATE (object);
/* close all folders that were opened for appending */
- close_folders (CAMEL_FILTER_DRIVER (object));
+ close_folders (CAMEL_FILTER_DRIVER (object), NULL);
g_hash_table_destroy (priv->folders);
g_hash_table_foreach (priv->globals, free_hash_strings, object);
@@ -1218,24 +1218,37 @@ open_folder (CamelFilterDriver *driver,
return camelfolder;
}
+typedef struct _CloseFolderData {
+ CamelFilterDriver *driver;
+ GCancellable *cancellable;
+} CloseFolderData;
+
static void
close_folder (gpointer key,
gpointer value,
- gpointer data)
+ gpointer user_data)
{
CamelFolder *folder = value;
- CamelFilterDriver *driver = data;
+ CamelFilterDriver *driver;
+ CloseFolderData *cfd = user_data;
+
+ g_return_if_fail (cfd != NULL);
+
+ driver = cfd->driver;
driver->priv->closed++;
g_free (key);
if (folder != FOLDER_INVALID) {
- /* FIXME Pass a GCancellable */
- if (camel_folder_synchronize_sync (folder, FALSE, NULL,
- (driver->priv->error != NULL) ? NULL : &driver->priv->error))
- camel_folder_refresh_info_sync (
- folder, NULL,
- (driver->priv->error != NULL) ? NULL : &driver->priv->error);
+ if (camel_folder_synchronize_sync (folder, FALSE, cfd->cancellable,
+ (driver->priv->error != NULL) ? NULL : &driver->priv->error)) {
+ if (cfd->cancellable) {
+ camel_folder_refresh_info_sync (
+ folder, cfd->cancellable,
+ (driver->priv->error != NULL) ? NULL : &driver->priv->error);
+ }
+ }
+
camel_folder_thaw (folder);
g_object_unref (folder);
}
@@ -1248,14 +1261,21 @@ close_folder (gpointer key,
/* flush/close all folders */
static gint
-close_folders (CamelFilterDriver *driver)
+close_folders (CamelFilterDriver *driver,
+ GCancellable *cancellable)
{
+ CloseFolderData cfd;
+
report_status (
driver, CAMEL_FILTER_STATUS_PROGRESS,
0, _("Syncing folders"));
driver->priv->closed = 0;
- g_hash_table_foreach (driver->priv->folders, close_folder, driver);
+
+ cfd.driver = driver;
+ cfd.cancellable = cancellable;
+
+ g_hash_table_foreach (driver->priv->folders, close_folder, &cfd);
g_hash_table_destroy (driver->priv->folders);
driver->priv->folders = g_hash_table_new (g_str_hash, g_str_equal);
@@ -1677,6 +1697,8 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver,
if (freeuids)
camel_folder_free_uids (folder, uids);
+ close_folders (driver, cancellable);
+
return status;
}
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index f64a0af..5a34ca2 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -1399,7 +1399,8 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
camel_operation_progress (cancellable, cnt ? cnt : 1);
}
- camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
+ if (camel_imapx_server_is_in_idle (is) && !camel_folder_is_frozen (folder))
+ camel_folder_summary_save (camel_folder_get_folder_summary (folder),
NULL);
}
g_clear_object (&mi);
@@ -5715,11 +5716,11 @@ camel_imapx_server_sync_changes_sync (CamelIMAPXServer *is,
camel_store_summary_info_unref (CAMEL_IMAPX_STORE (parent_store)->summary,
si);
}
}
-
- camel_folder_summary_save (folder_summary, NULL);
- camel_store_summary_save (CAMEL_IMAPX_STORE (parent_store)->summary);
}
+ camel_folder_summary_save (camel_folder_get_folder_summary (folder), NULL);
+ camel_store_summary_save (CAMEL_IMAPX_STORE (camel_folder_get_parent_store (folder))->summary);
+
imapx_sync_free_user (on_user);
imapx_sync_free_user (off_user);
camel_folder_free_uids (folder, changed_uids);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]