diff options
author | Not Zed <NotZed@Ximian.com> | 2004-06-29 18:05:21 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-06-29 18:05:21 +0800 |
commit | be9d78b480acdc44a88c9c00f021fe96bf4db442 (patch) | |
tree | 2f28dfacb27dc42bf2f39b6e81933ec59f7e7927 | |
parent | 619bfef832b9b8fd928d1d2ab0fe4720fd6a5fc0 (diff) | |
download | gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar.gz gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar.bz2 gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar.lz gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar.xz gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.tar.zst gsoc2013-evolution-be9d78b480acdc44a88c9c00f021fe96bf4db442.zip |
add any parents of the new name before we actually do the rename so the
2004-06-29 Not Zed <NotZed@Ximian.com>
* 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.
svn path=/trunk/; revision=26546
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-vee-store.c | 32 |
2 files changed, 33 insertions, 5 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index d2dc504619..e35319056b 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2004-06-29 Not Zed <NotZed@Ximian.com> + + * 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 <NotZed@Ximian.com> * providers/local/camel-maildir-folder.c (maildir_folder_getv): diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c index bb8cf22b2c..d0ef62aff4 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); } |