From 4b8e2db48961f3bc7becd6132adefd9904ae6a7a Mon Sep 17 00:00:00 2001 From: 8 Date: Sun, 28 Oct 2001 13:05:36 +0000 Subject: Changed to call ibex_move to rename it internally. 2001-10-28 * providers/local/camel-local-store.c (rename_folder): Changed to call ibex_move to rename it internally. svn path=/trunk/; revision=14294 --- camel/ChangeLog | 6 +++- camel/providers/local/camel-local-store.c | 53 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 10 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 9b7415e91c..59c97b3a78 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,6 +1,10 @@ 2001-10-28 - * camel-store.c (camel_store_rename_folder): Use the right variable, not info. + * providers/local/camel-local-store.c (rename_folder): Changed to + call ibex_move to rename it internally. + + * camel-store.c (camel_store_rename_folder): Use the right + variable, not info. 2001-10-28 Jeffrey Stedfast diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c index 9b48b91175..32ca801606 100644 --- a/camel/providers/local/camel-local-store.c +++ b/camel/providers/local/camel-local-store.c @@ -29,10 +29,16 @@ #include #include +#include + +#include "camel-private.h" + #include "camel-local-store.h" #include "camel-exception.h" #include "camel-url.h" +#include "camel-local-folder.h" + #define d(x) /* Returns the class for a CamelLocalStore */ @@ -305,19 +311,48 @@ static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex) { char *path = CAMEL_LOCAL_STORE (store)->toplevel_dir; + CamelLocalFolder *folder; + char *newibex = g_strdup_printf("%s%s.ibex", path, new); + char *oldibex = g_strdup_printf("%s%s.ibex", path, old); /* try to rollback failures, has obvious races */ - if (xrename(old, new, path, ".ibex", TRUE, ex)) { - return; - } - if (xrename(old, new, path, ".ev-summary", TRUE, ex)) { - xrename(new, old, path, ".ibex", TRUE, ex); - return; + + CAMEL_STORE_LOCK(store, cache_lock); + folder = g_hash_table_lookup(store->folders, old); + if (folder) { + if (ibex_move(folder->index, newibex) == -1) + goto ibex_failed; + } else { + if (xrename(old, new, path, ".ibex", TRUE, ex)) + goto ibex_failed; } - if (xrename(old, new, path, "", FALSE, ex)) { - xrename(new, old, path, ".ev-summary", TRUE, ex); + + if (xrename(old, new, path, ".ev-summary", TRUE, ex)) + goto summary_failed; + + if (xrename(old, new, path, "", FALSE, ex)) + goto base_failed; + + CAMEL_STORE_UNLOCK(store, cache_lock); + + g_free(newibex); + g_free(oldibex); + + return; + +base_failed: + xrename(new, old, path, ".ev-summary", TRUE, ex); + +summary_failed: + if (folder) + ibex_move(folder->index, oldibex); + else xrename(new, old, path, ".ibex", TRUE, ex); - } + +ibex_failed: + CAMEL_STORE_UNLOCK(store, cache_lock); + g_free(newibex); + g_free(oldibex); } /* default implementation, only delete metadata */ -- cgit