From: Not Zed Date: Tue, 29 Jun 2004 10:05:21 +0000 (+0000) Subject: add any parents of the new name before we actually do the rename so the X-Git-Tag: upstream/3.7.4~8585 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5811588a469faf0a07465bdda34b625686ad877b;p=platform%2Fupstream%2Fevolution-data-server.git add any parents of the new name before we actually do the rename so the 2004-06-29 Not Zed * camel-vee-store.c (vee_rename_folder): add any parents of the new name before we actually do the rename so the rename has somewhere to go to. #60775. --- diff --git a/camel/ChangeLog b/camel/ChangeLog index d2dc504..e353190 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2004-06-29 Not Zed + + * camel-vee-store.c (vee_rename_folder): add any parents of the + new name before we actually do the rename so the rename has + somewhere to go to. #60775. + 2004-06-28 Not Zed * providers/local/camel-maildir-folder.c (maildir_folder_getv): diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c index bb8cf22..d0ef62a 100644 --- a/camel/camel-vee-store.c +++ b/camel/camel-vee-store.c @@ -378,7 +378,8 @@ vee_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex static void vee_rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex) { - CamelFolder *folder; + CamelFolder *folder, *oldfolder; + char *p, *name; d(printf("vee rename folder '%s' '%s'\n", old, new)); @@ -389,11 +390,32 @@ vee_rename_folder(CamelStore *store, const char *old, const char *new, CamelExce } /* See if it exists, for vfolders, all folders are in the folders hash */ - folder = camel_object_bag_get(store->folders, old); - if (folder == NULL) { + oldfolder = camel_object_bag_get(store->folders, old); + if (oldfolder == NULL) { camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER, _("Cannot rename folder: %s: No such folder"), old); - } else { - camel_object_unref(folder); + return; } + + /* Check that new parents exist, if not, create dummy ones */ + name = alloca(strlen(new)+1); + strcpy(name, new); + p = name; + while ( (p = strchr(p, '/'))) { + *p = 0; + + folder = camel_object_bag_reserve(store->folders, name); + if (folder == NULL) { + /* create a dummy vFolder for this, makes get_folder_info simpler */ + folder = camel_vee_folder_new(store, name, ((CamelVeeFolder *)oldfolder)->flags); + camel_object_bag_add(store->folders, name, folder); + change_folder(store, name, CHANGE_ADD|CHANGE_NOSELECT, 0); + /* FIXME: this sort of leaks folder, nobody owns a ref to it but us */ + } else { + camel_object_unref(folder); + } + *p++='/'; + } + + camel_object_unref(oldfolder); }