aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/providers/local/camel-mbox-store.c46
2 files changed, 48 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 079ba07eaf..d9308f0c6d 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2004-01-28 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/local/camel-mbox-store.c (rename_folder): Make sure
+ the new dir path exists before trying to rename files to avoid
+ ENOENT errors. Also save errno when we encounter errors so that we
+ can report the true error later rather than an error we may get
+ while reverting changes. Also, it is OK if the ibex files don't
+ exist, so check for that errno case.
+
2004-01-28 Sivaih Nallagatla <snallagatla@novell.com>
* providers/groupwise/camel-gw-listener.c (account_changed)
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 0a6dfe0200..74bf94579f 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -446,10 +446,10 @@ static void
rename_folder (CamelStore *store, const char *old, const char *new, CamelException *ex)
{
CamelLocalFolder *folder = NULL;
- char *oldibex, *newibex;
+ char *oldibex, *newibex, *newdir;
+ int errnosav;
if (new[0] == '.' || ignore_file (new, TRUE)) {
- printf ("exception: The new folder name is illegal.\n");
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("The new folder name is illegal."));
return;
@@ -460,21 +460,46 @@ rename_folder (CamelStore *store, const char *old, const char *new, CamelExcepti
oldibex = mbox_folder_name_to_meta_path (store, old, ".ibex");
newibex = mbox_folder_name_to_meta_path (store, new, ".ibex");
+ newdir = g_path_get_dirname (newibex);
+ if (camel_mkdir (newdir, 0777) == -1) {
+ if (errno != EEXIST) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not rename `%s': `%s': %s"),
+ old, new, g_strerror (errno));
+ g_free (oldibex);
+ g_free (newibex);
+ g_free (newdir);
+
+ return;
+ }
+
+ g_free (newdir);
+ newdir = NULL;
+ }
+
folder = camel_object_bag_get (store->folders, old);
if (folder && folder->index) {
- if (camel_index_rename (folder->index, newibex) == -1)
+ if (camel_index_rename (folder->index, newibex) == -1 && errno != ENOENT) {
+ errnosav = errno;
goto ibex_failed;
+ }
} else {
/* TODO: camel_text_index_rename should find out if we have an active index itself? */
- if (camel_text_index_rename (oldibex, newibex) == -1)
+ if (camel_text_index_rename (oldibex, newibex) == -1 && errno != ENOENT) {
+ errnosav = errno;
goto ibex_failed;
+ }
}
- if (xrename (store, old, new, ".ev-summary", TRUE, ex))
+ if (xrename (store, old, new, ".ev-summary", TRUE, ex) == -1) {
+ errnosav = errno;
goto summary_failed;
+ }
- if (xrename (store, old, new, NULL, FALSE, ex))
+ if (xrename (store, old, new, NULL, FALSE, ex) == -1) {
+ errnosav = errno;
goto base_failed;
+ }
g_free (oldibex);
g_free (newibex);
@@ -495,11 +520,18 @@ rename_folder (CamelStore *store, const char *old, const char *new, CamelExcepti
camel_index_rename (folder->index, oldibex);
} else
camel_text_index_rename (newibex, oldibex);
+
ibex_failed:
+ if (newdir) {
+ /* newdir is only non-NULL if we needed to mkdir */
+ rmdir (newdir);
+ g_free (newdir);
+ }
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not rename '%s': %s"),
- old, g_strerror (errno));
+ old, g_strerror (errnosav));
g_free (newibex);
g_free (oldibex);