diff options
Diffstat (limited to 'camel/providers/local/camel-local-folder.c')
-rw-r--r-- | camel/providers/local/camel-local-folder.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index d84041025c..0344fc8952 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -50,6 +50,8 @@ #include "camel-local-private.h" +#include "camel-text-index.h" + #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/ #ifndef PATH_MAX @@ -138,9 +140,8 @@ local_finalize(CamelObject * object) camel_object_unref((CamelObject *)local_folder->search); } - /* must free index after summary, since it isn't refcounted */ if (local_folder->index) - ibex_close(local_folder->index); + camel_object_unref((CamelObject *)local_folder->index); while (local_folder->locked> 0) camel_local_folder_unlock(local_folder); @@ -211,10 +212,17 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con lf->changes = camel_folder_change_info_new(); - /* if we have no index file, force it */ - forceindex = stat(lf->index_path, &st) == -1; + /* TODO: Remove the following line, it is a temporary workaround to remove + the old-format 'ibex' files that might be lying around */ + unlink(lf->index_path); + + /* if we have no/invalid index file, force it */ + forceindex = camel_text_index_check(lf->index_path) == -1; if (flags & CAMEL_STORE_FOLDER_BODY_INDEX) { - lf->index = ibex_open(lf->index_path, O_CREAT | O_RDWR, 0600); + int flag = O_RDWR|O_CREAT; + if (forceindex) + flag |= O_TRUNC; + lf->index = (CamelIndex *)camel_text_index_new(lf->index_path, flag); if (lf->index == NULL) { /* yes, this isn't fatal at all */ g_warning("Could not open/create index file: %s: indexing not performed", strerror(errno)); @@ -223,10 +231,9 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX; } } else { - /* if we do have an index file, remove it */ - if (forceindex == FALSE) { - unlink(lf->index_path); - } + /* if we do have an index file, remove it (?) */ + if (forceindex == FALSE) + camel_text_index_remove(lf->index_path); forceindex = FALSE; } @@ -237,7 +244,9 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con camel_exception_clear(ex); } - if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) { + /*if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) {*/ + /* we sync here so that any hard work setting up the folder isn't lost */ + if (camel_local_summary_sync((CamelLocalSummary *)folder->summary, FALSE, lf->changes, ex) == -1) { camel_object_unref (CAMEL_OBJECT (folder)); return NULL; } |