diff options
author | Not Zed <NotZed@Ximian.com> | 2002-09-24 09:16:12 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-09-24 09:16:12 +0800 |
commit | a65c7bb4769b16dda87c1bdf2cb06784b4090d4a (patch) | |
tree | 8e77d9424cf98f558b57a1174c621bb014740ec8 /camel/camel-index.c | |
parent | 5ca425852cab78a782c1b354555f7c9c380d8e02 (diff) | |
download | gsoc2013-evolution-a65c7bb4769b16dda87c1bdf2cb06784b4090d4a.tar.gz gsoc2013-evolution-a65c7bb4769b16dda87c1bdf2cb06784b4090d4a.tar.zst gsoc2013-evolution-a65c7bb4769b16dda87c1bdf2cb06784b4090d4a.zip |
If we have no data written to a key, dont add it, or its partition header.
2002-09-24 Not Zed <NotZed@Ximian.com>
* camel-text-index.c (text_index_compress_nosync): If we have no
data written to a key, dont add it, or its partition header.
2002-09-23 Not Zed <NotZed@Ximian.com>
* camel-block-file.c (sync_nolock): Mark root block dirty if we're
going to sync it.
(camel_key_file_finalise): de-count the active list if we close
it.
* camel-text-index.c (text_index_delete): Implement.
(text_index_compress_nosync): Use index_delete when we're finished
with the old one, so it is properly deactivated.
* camel-index.c (camel_index_delete): Remove api call. Mark index
deleted in new state variable.
(camel_index_*): Wrap all calls in check for deleted state.
svn path=/trunk/; revision=18189
Diffstat (limited to 'camel/camel-index.c')
-rw-r--r-- | camel/camel-index.c | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/camel/camel-index.c b/camel/camel-index.c index eb476b41fc..ea7a63fe08 100644 --- a/camel/camel-index.c +++ b/camel/camel-index.c @@ -116,7 +116,12 @@ camel_index_construct(CamelIndex *idx, const char *path, int flags) int camel_index_rename(CamelIndex *idx, const char *path) { - return CI_CLASS(idx)->rename(idx, path); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->rename(idx, path); + else { + errno = ENOENT; + return -1; + } } void @@ -129,43 +134,84 @@ camel_index_set_normalise(CamelIndex *idx, CamelIndexNorm func, void *data) int camel_index_sync(CamelIndex *idx) { - return CI_CLASS(idx)->sync(idx); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->sync(idx); + else { + errno = ENOENT; + return -1; + } } int camel_index_compress(CamelIndex *idx) { - return CI_CLASS(idx)->compress(idx); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->compress(idx); + else { + errno = ENOENT; + return -1; + } +} + +int +camel_index_delete(CamelIndex *idx) +{ + int ret; + + if ((idx->state & CAMEL_INDEX_DELETED) == 0) { + ret = CI_CLASS(idx)->delete(idx); + idx->state |= CAMEL_INDEX_DELETED; + } else { + errno = ENOENT; + ret = -1; + } + + return ret; } int camel_index_has_name(CamelIndex *idx, const char *name) { - return CI_CLASS(idx)->has_name(idx, name); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->has_name(idx, name); + else + return FALSE; } CamelIndexName * camel_index_add_name(CamelIndex *idx, const char *name) { - return CI_CLASS(idx)->add_name(idx, name); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->add_name(idx, name); + else + return NULL; } int camel_index_write_name(CamelIndex *idx, CamelIndexName *idn) { - return CI_CLASS(idx)->write_name(idx, idn); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->write_name(idx, idn); + else { + errno = ENOENT; + return -1; + } } CamelIndexCursor * camel_index_find_name(CamelIndex *idx, const char *name) { - return CI_CLASS(idx)->find_name(idx, name); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->find_name(idx, name); + else + return NULL; } void camel_index_delete_name(CamelIndex *idx, const char *name) { - return CI_CLASS(idx)->delete_name(idx, name); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + CI_CLASS(idx)->delete_name(idx, name); } CamelIndexCursor * @@ -174,6 +220,9 @@ camel_index_find(CamelIndex *idx, const char *word) char *b = (char *)word; CamelIndexCursor *ret; + if ((idx->state & CAMEL_INDEX_DELETED) != 0) + return NULL; + if (idx->normalise) b = idx->normalise(idx, word, idx->normalise_data); @@ -188,13 +237,19 @@ camel_index_find(CamelIndex *idx, const char *word) CamelIndexCursor * camel_index_words(CamelIndex *idx) { - return CI_CLASS(idx)->words(idx); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->words(idx); + else + return NULL; } CamelIndexCursor * camel_index_names(CamelIndex *idx) { - return CI_CLASS(idx)->names(idx); + if ((idx->state & CAMEL_INDEX_DELETED) == 0) + return CI_CLASS(idx)->names(idx); + else + return NULL; } /* ********************************************************************** */ |