Folder creation does not update folder list



When creating a (sub)folder with tinymail, a subsequent call to
tny_folder_store_get_folders does not include the newly-created folder
(in libtinymail-camel). I attached a patch that calls
camel_store_get_folder_info() again after folder creation.

Probably a better solution would not have to query the server, but I am
unsure how to achieve that. The CamelFolderInfo returned from
camel_store_create_folder does not seem to be linked with the infos
cached by TnyCamelStoreAccount and/or TnyCamelFolder.

Thanks,
Armin
Index: libtinymail-camel/tny-camel-folder.c
===================================================================
--- libtinymail-camel/tny-camel-folder.c	(revision 2459)
+++ libtinymail-camel/tny-camel-folder.c	(working copy)
@@ -3767,6 +3767,14 @@
 	folder = _tny_camel_folder_new ();
 	_tny_camel_folder_set_folder_info (self, TNY_CAMEL_FOLDER (folder), info);
 
+	/* So that the next call to get_folders includes the newly
+	 * created folder */
+	if(!priv->iter_parented && priv->iter)
+		camel_folder_info_free (priv->iter);
+
+	priv->iter = camel_store_get_folder_info (store, priv->folder_name, 0, &subex);
+	priv->iter_parented = FALSE;
+
 	change = tny_folder_store_change_new (self);
 	tny_folder_store_change_add_created_folder (change, folder);
 	notify_folder_store_observers_about (self, change);
Index: libtinymail-camel/tny-camel-store-account.c
===================================================================
--- libtinymail-camel/tny-camel-store-account.c	(revision 2459)
+++ libtinymail-camel/tny-camel-store-account.c	(working copy)
@@ -805,6 +805,7 @@
 tny_camel_store_account_create_folder_default (TnyFolderStore *self, const gchar *name, GError **err)
 {
 	TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self);
+	TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self);    
 	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 	TnyFolder *folder; CamelFolderInfo *info; CamelStore *store;
 	TnyFolderStoreChange *change;
@@ -880,6 +881,10 @@
 	folder = _tny_camel_folder_new ();
 	_tny_camel_folder_set_folder_info (self, TNY_CAMEL_FOLDER (folder), info);
 
+	/* So that the next call to get_folders() includes the newly-created
+	 * folder. */
+	priv->cant_reuse_iter = TRUE;
+
 	change = tny_folder_store_change_new (self);
 	tny_folder_store_change_add_created_folder (change, folder);
 	notify_folder_store_observers_about (self, change);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2459)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2007-07-11  Armin Burgmeier  <armin openismus com>
+
+	* libtinymail-camel/tny-camel-folder.c:
+	* libtinymail-camel/tny-camel-store-account.c: Recreate folder list
+	after a new folder has been created so that subsequent calls to
+	_get_folder() contain the newly created folder.
+
 2007-07-11 Dirk-Jan C. Binnema <dirk-jan binnema nokia com>
 	* Don't set subject to 'No Subject' if it's empty
 	(camel-mime-message.c)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]