aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-04-18 16:15:51 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-04-18 16:15:51 +0800
commitff664c121a4c64b04307b6c00566c03d559a8545 (patch)
tree3550a2d74ff0bf6b56004c0c87fbd5ae3c5fe598
parent2243175b0cff12404b8beb0b14801cec4d7e5304 (diff)
downloadgsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.gz
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.bz2
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.lz
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.xz
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.zst
gsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.zip
If we get a failure, make sure we set an exception.
2002-04-18 Not Zed <NotZed@Ximian.com> * providers/local/camel-local-store.c (rename_folder): If we get a failure, make sure we set an exception. * camel-text-index.c (camel_text_index_rename): If the file doesn't exist, just assume it never did, dont return failure. (text_index_rename): Add '.index' to the path name we're using, since we dont get it passed in. svn path=/trunk/; revision=16505
-rw-r--r--camel/ChangeLog8
-rw-r--r--camel/camel-text-index.c18
-rw-r--r--camel/providers/local/camel-local-store.c8
3 files changed, 24 insertions, 10 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index ad285fa52b..c2b7d9d9c3 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,13 @@
2002-04-18 Not Zed <NotZed@Ximian.com>
+ * providers/local/camel-local-store.c (rename_folder): If we get a
+ failure, make sure we set an exception.
+
+ * camel-text-index.c (camel_text_index_rename): If the file
+ doesn't exist, just assume it never did, dont return failure.
+ (text_index_rename): Add '.index' to the path name we're using,
+ since we dont get it passed in.
+
* camel-folder-search.c (check_header): When doing a contains
match, split the words and perform an and on it.
(match_words_messages): If we have an index, but were forced to do
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index 9638ae6269..9822df85f1 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -516,30 +516,32 @@ static int
text_index_rename(CamelIndex *idx, const char *path)
{
struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
- char *newlink;
+ char *newlink, *newblock;
int err, ret;
CAMEL_TEXT_INDEX_LOCK(idx, lock);
- ret = camel_block_file_rename(p->blocks, path);
+ newblock = alloca(strlen(path)+8);
+ sprintf(newblock, "%s.index", path);
+ ret = camel_block_file_rename(p->blocks, newblock);
if (ret == -1) {
CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
return -1;
}
- newlink = alloca(strlen(path)+8);
- sprintf(newlink, "%s.data", path);
+ newlink = alloca(strlen(path)+16);
+ sprintf(newlink, "%s.index.data", path);
ret = camel_key_file_rename(p->links, newlink);
if (ret == -1) {
err = errno;
- camel_block_file_rename(p->blocks, path);
+ camel_block_file_rename(p->blocks, idx->path);
CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
errno = err;
return -1;
}
g_free(idx->path);
- idx->path = g_strdup(path);
+ idx->path = g_strdup(newblock);
CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
@@ -909,13 +911,13 @@ camel_text_index_rename(const char *old, const char *new)
sprintf(oldname, "%s.index", old);
sprintf(newname, "%s.index", new);
- if (rename(oldname, newname) == -1)
+ if (rename(oldname, newname) == -1 && errno != ENOENT)
return -1;
sprintf(oldname, "%s.index.data", old);
sprintf(newname, "%s.index.data", new);
- if (rename(oldname, newname) == -1) {
+ if (rename(oldname, newname) == -1 && errno != ENOENT) {
err = errno;
sprintf(oldname, "%s.index", old);
sprintf(newname, "%s.index", new);
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 0e7be5f48b..6a51046814 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -40,7 +40,7 @@
#include "camel-local-folder.h"
#include <camel/camel-text-index.h>
-#define d(x)
+#define d(x)
/* Returns the class for a CamelLocalStore */
#define CLOCALS_CLASS(so) CAMEL_LOCAL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
@@ -323,7 +323,7 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio
CAMEL_STORE_LOCK(store, cache_lock);
folder = g_hash_table_lookup(store->folders, old);
if (folder && folder->index) {
- if (folder->index && camel_index_rename(folder->index, newibex) == -1)
+ 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? */
@@ -354,6 +354,10 @@ summary_failed:
} else
camel_text_index_rename(newibex, oldibex);
ibex_failed:
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Could not rename '%s': %s"),
+ old, strerror(errno));
+
CAMEL_STORE_UNLOCK(store, cache_lock);
g_free(newibex);
g_free(oldibex);