aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-text-index.c
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 /camel/camel-text-index.c
parent2243175b0cff12404b8beb0b14801cec4d7e5304 (diff)
downloadgsoc2013-evolution-ff664c121a4c64b04307b6c00566c03d559a8545.tar.gz
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
Diffstat (limited to 'camel/camel-text-index.c')
-rw-r--r--camel/camel-text-index.c18
1 files changed, 10 insertions, 8 deletions
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);