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
This commit is contained in:
committed by
Jeffrey Stedfast
parent
d2137f7fd9
commit
cd0f54e546
@ -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)
|
||||
|
||||
@ -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");
|
||||
|
||||
folder = camel_object_bag_get (store->folders, old);
|
||||
if (folder && folder->index) {
|
||||
if (camel_index_rename (folder->index, newibex) == -1)
|
||||
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)
|
||||
goto ibex_failed;
|
||||
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;
|
||||
}
|
||||
|
||||
if (xrename (store, old, new, ".ev-summary", TRUE, ex))
|
||||
goto summary_failed;
|
||||
folder = camel_object_bag_get (store->folders, old);
|
||||
if (folder && folder->index) {
|
||||
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 && errno != ENOENT) {
|
||||
errnosav = errno;
|
||||
goto ibex_failed;
|
||||
}
|
||||
}
|
||||
|
||||
if (xrename (store, old, new, NULL, FALSE, ex))
|
||||
if (xrename (store, old, new, ".ev-summary", TRUE, ex) == -1) {
|
||||
errnosav = errno;
|
||||
goto summary_failed;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user