aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local
diff options
context:
space:
mode:
author8 <NotZed@Ximian.com>2001-10-28 21:05:36 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-28 21:05:36 +0800
commit4b8e2db48961f3bc7becd6132adefd9904ae6a7a (patch)
tree4cd835d5e7a8b6cfb32dd42e22c908d07ead9b5a /camel/providers/local
parentcf90bb5d3354ed745a7e0fd1ceb13ea8c28a8b58 (diff)
downloadgsoc2013-evolution-4b8e2db48961f3bc7becd6132adefd9904ae6a7a.tar.gz
gsoc2013-evolution-4b8e2db48961f3bc7becd6132adefd9904ae6a7a.tar.zst
gsoc2013-evolution-4b8e2db48961f3bc7becd6132adefd9904ae6a7a.zip
Changed to call ibex_move to rename it internally.
2001-10-28 <NotZed@Ximian.com> * providers/local/camel-local-store.c (rename_folder): Changed to call ibex_move to rename it internally. svn path=/trunk/; revision=14294
Diffstat (limited to 'camel/providers/local')
-rw-r--r--camel/providers/local/camel-local-store.c53
1 files changed, 44 insertions, 9 deletions
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 <unistd.h>
#include <stdio.h>
+#include <glib.h>
+
+#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 */