diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-01-29 01:51:13 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-01-29 01:51:13 +0800 |
commit | cd0f54e5465d95dfee6f4fb64d47a97301997dfe (patch) | |
tree | 36ee6e2effce9478a9149dd4bb959e2de34e8d2b | |
parent | d2137f7fd934247cf02b3bde7dce04209f5b73c2 (diff) | |
download | gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar.gz gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar.bz2 gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar.lz gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar.xz gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.tar.zst gsoc2013-evolution-cd0f54e5465d95dfee6f4fb64d47a97301997dfe.zip |
Make sure the new dir path exists before trying to rename files to avoid
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.
svn path=/trunk/; revision=24496
-rw-r--r-- | camel/ChangeLog | 9 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-store.c | 46 |
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); |