[evolution-data-server/gnome-41] IMAPx: Avoid creating NOSELECT CamelFolder-s
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-41] IMAPx: Avoid creating NOSELECT CamelFolder-s
- Date: Tue, 11 Jan 2022 10:32:37 +0000 (UTC)
commit 7b31352feb3867b6016b110afa00a6c460079e30
Author: Milan Crha <mcrha redhat com>
Date: Tue Jan 11 11:26:12 2022 +0100
IMAPx: Avoid creating NOSELECT CamelFolder-s
When a folder is set as NOSELECT, it should not be instantiated
as a CamelFolder object, because the folder may not even exist
on the server. The instance also creates a table in the folders.db
database with no content.
The #373 has a `Folders` folder, whose name clashes with Camel's
`folders' table consisting of the information about the stored folders.
Related to https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/373
src/camel/providers/imapx/camel-imapx-store.c | 47 ++++++++++++++++++---------
1 file changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-store.c b/src/camel/providers/imapx/camel-imapx-store.c
index 0fd85f4a7..a4ef9bea3 100644
--- a/src/camel/providers/imapx/camel-imapx-store.c
+++ b/src/camel/providers/imapx/camel-imapx-store.c
@@ -1137,7 +1137,7 @@ get_folder_offline (CamelStore *store,
si = camel_store_summary_path (imapx_store->summary, folder_name);
- if (si != NULL) {
+ if (si != NULL && !(si->flags & CAMEL_STORE_INFO_FOLDER_NOSELECT)) {
gchar *base_dir;
gchar *folder_dir;
@@ -1147,8 +1147,6 @@ get_folder_offline (CamelStore *store,
store, folder_dir, folder_name, error);
g_free (folder_dir);
g_free (base_dir);
-
- camel_store_summary_info_unref (imapx_store->summary, si);
} else {
g_set_error (
error, CAMEL_STORE_ERROR,
@@ -1156,6 +1154,9 @@ get_folder_offline (CamelStore *store,
_("No such folder %s"), folder_name);
}
+ if (si)
+ camel_store_summary_info_unref (imapx_store->summary, si);
+
return new_folder;
}
@@ -1962,10 +1963,11 @@ imapx_can_refresh_folder (CamelStore *store,
subscribed = ((info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
- res = store_class->can_refresh_folder (store, info, &local_error) ||
- check_all || (check_subscribed && subscribed);
+ res = !(info->flags & CAMEL_FOLDER_NOSELECT) && (
+ store_class->can_refresh_folder (store, info, &local_error) ||
+ check_all || (check_subscribed && subscribed));
- if (!res && !local_error) {
+ if (!res && !local_error && !(info->flags & CAMEL_FOLDER_NOSELECT)) {
CamelFolder *folder;
folder = camel_store_get_folder_sync (store, info->full_name, 0, NULL, &local_error);
@@ -2276,6 +2278,7 @@ imapx_store_create_folder_sync (CamelStore *store,
CamelFolder *folder;
CamelIMAPXMailbox *parent_mailbox = NULL;
CamelFolderInfo *fi = NULL;
+ CamelStoreInfo *si;
GList *list;
const gchar *namespace_prefix;
const gchar *parent_mailbox_name;
@@ -2291,6 +2294,16 @@ imapx_store_create_folder_sync (CamelStore *store,
/* Obtain the separator from the parent CamelIMAPXMailbox. */
+ si = camel_store_summary_path (imapx_store->summary, parent_name);
+
+ if (!si || (si->flags & CAMEL_STORE_INFO_FOLDER_NOSELECT) != 0) {
+ if (si)
+ camel_store_summary_info_unref (imapx_store->summary, si);
+ goto check_namespace;
+ }
+
+ camel_store_summary_info_unref (imapx_store->summary, si);
+
folder = camel_store_get_folder_sync (
store, parent_name, 0, cancellable, error);
@@ -2842,20 +2855,22 @@ imapx_store_dup_downsync_folders_recurse (CamelStore *store,
GPtrArray **inout_folders)
{
while (info) {
- CamelFolder *folder;
-
if (info->child)
imapx_store_dup_downsync_folders_recurse (store, info->child, inout_folders);
- folder = camel_store_get_folder_sync (store, info->full_name, 0, NULL, NULL);
- if (folder && CAMEL_IS_IMAPX_FOLDER (folder) &&
- camel_offline_folder_can_downsync (CAMEL_OFFLINE_FOLDER (folder))) {
- if (!*inout_folders)
- *inout_folders = g_ptr_array_sized_new (32);
- g_ptr_array_add (*inout_folders, g_object_ref (folder));
- }
+ if (!(info->flags & CAMEL_FOLDER_NOSELECT)) {
+ CamelFolder *folder;
- g_clear_object (&folder);
+ folder = camel_store_get_folder_sync (store, info->full_name, 0, NULL, NULL);
+ if (folder && CAMEL_IS_IMAPX_FOLDER (folder) &&
+ camel_offline_folder_can_downsync (CAMEL_OFFLINE_FOLDER (folder))) {
+ if (!*inout_folders)
+ *inout_folders = g_ptr_array_sized_new (32);
+ g_ptr_array_add (*inout_folders, g_object_ref (folder));
+ }
+
+ g_clear_object (&folder);
+ }
info = info->next;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]