diff options
author | Not Zed <NotZed@Ximian.com> | 2002-03-25 20:11:44 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-03-25 20:11:44 +0800 |
commit | c6fc4e27a953c5213cff8400ec8e40f6f051e914 (patch) | |
tree | 7237e42f705cd584d36f3a2a4795a1bb16741dd3 /camel/providers/local/camel-maildir-summary.c | |
parent | ede63cde5882af8696c22ed546506ad877b73011 (diff) | |
download | gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar.gz gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar.bz2 gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar.lz gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar.xz gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.tar.zst gsoc2013-evolution-c6fc4e27a953c5213cff8400ec8e40f6f051e914.zip |
When we add a new name, up all of the cache limits, because we're probably
2002-03-25 Not Zed <NotZed@Ximian.com>
* camel-text-index.c (text_index_add_name): When we add a new
name, up all of the cache limits, because we're probably going to
be adding more.
(text_index_sync): Drop the cache limits back down again, we dont
need them when looking words up.
** MERGE camel_index branch.
* camel-text-index.[ch]: Added files i forgot to add (eep nearly
lost all this work!)
* camel-block-file.c (sync_nolock): Fix an infinite loop in syncing.
svn path=/trunk/; revision=16242
Diffstat (limited to 'camel/providers/local/camel-maildir-summary.c')
-rw-r--r-- | camel/providers/local/camel-maildir-summary.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c index 1cfcf50a88..b0bd172257 100644 --- a/camel/providers/local/camel-maildir-summary.c +++ b/camel/providers/local/camel-maildir-summary.c @@ -22,7 +22,9 @@ #include <config.h> #endif +#include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include <sys/uio.h> #include <unistd.h> #include <errno.h> @@ -36,6 +38,7 @@ #include "camel-maildir-summary.h" #include <camel/camel-mime-message.h> +#include <camel/camel-operation.h> #include "camel-private.h" #include "e-util/e-memory.h" @@ -152,7 +155,7 @@ camel_maildir_summary_finalise(CamelObject *obj) * * Return value: A new #CamelMaildirSummary object. **/ -CamelMaildirSummary *camel_maildir_summary_new (const char *filename, const char *maildirdir, ibex *index) +CamelMaildirSummary *camel_maildir_summary_new (const char *filename, const char *maildirdir, CamelIndex *index) { CamelMaildirSummary *o = (CamelMaildirSummary *)camel_object_new(camel_maildir_summary_get_type ()); @@ -457,7 +460,7 @@ static int camel_maildir_summary_add(CamelLocalSummary *cls, const char *name, i mp = camel_mime_parser_new(); camel_mime_parser_scan_from(mp, FALSE); camel_mime_parser_init_with_fd(mp, fd); - if (cls->index && (forceindex || !ibex_contains_name(cls->index, (char *)name))) { + if (cls->index && (forceindex || !camel_index_has_name(cls->index, name))) { d(printf("forcing indexing of message content\n")); camel_folder_summary_set_index((CamelFolderSummary *)maildirs, cls->index); } else { @@ -477,7 +480,7 @@ remove_summary(char *key, CamelMessageInfo *info, CamelLocalSummary *cls) { d(printf("removing message %s from summary\n", key)); if (cls->index) - ibex_unindex(cls->index, (char *)camel_message_info_uid(info)); + camel_index_delete_name(cls->index, camel_message_info_uid(info)); camel_folder_summary_remove((CamelFolderSummary *)cls, info); camel_folder_summary_info_free((CamelFolderSummary *)cls, info); } @@ -507,7 +510,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca CamelMaildirMessageInfo *mdi; CamelFolderSummary *s = (CamelFolderSummary *)cls; GHashTable *left; - int i, count; + int i, count, total; int forceindex; char *new, *cur; char *uid; @@ -519,6 +522,8 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca d(printf("checking summary ...\n")); + camel_operation_start(NULL, _("Checking folder consistency")); + /* scan the directory, check for mail files not in the index, or index entries that no longer exist */ dir = opendir(cur); @@ -526,6 +531,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca camel_exception_setv(ex, 1, _("Cannot open maildir directory path: %s: %s"), cls->folder_path, strerror(errno)); g_free(cur); g_free(new); + camel_operation_end(NULL); return -1; } @@ -540,7 +546,19 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca } } + /* joy, use this to pre-count the total, so we can report progress meaningfully */ + total = 0; + count = 0; + while ( (d = readdir(dir)) ) + total++; + rewinddir(dir); + while ( (d = readdir(dir)) ) { + int pc = count * 100 / total; + + camel_operation_progress(NULL, pc); + count++; + /* FIXME: also run stat to check for regular file */ p = d->d_name; if (p[0] == '.') @@ -554,7 +572,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca uid = g_strdup(d->d_name); info = camel_folder_summary_uid((CamelFolderSummary *)cls, uid); - if (info == NULL || (cls->index && (!ibex_contains_name(cls->index, uid)))) { + if (info == NULL || (cls->index && (!camel_index_has_name(cls->index, uid)))) { /* need to add this file to the summary */ if (info != NULL) { CamelMessageInfo *old = g_hash_table_lookup(left, camel_message_info_uid(info)); @@ -606,12 +624,26 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca g_hash_table_foreach(left, (GHFunc)remove_summary, cls); g_hash_table_destroy(left); + camel_operation_end(NULL); + + camel_operation_start(NULL, _("Checking for new messages")); + /* now, scan new for new messages, and copy them to cur, and so forth */ dir = opendir(new); if (dir != NULL) { + total = 0; + count = 0; + while ( (d = readdir(dir)) ) + total++; + rewinddir(dir); + while ( (d = readdir(dir)) ) { char *name, *newname, *destname, *destfilename; char *src, *dest; + int pc = count * 100 / total; + + camel_operation_progress(NULL, pc); + count++; name = d->d_name; if (name[0] == '.') @@ -650,6 +682,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca g_free(src); g_free(dest); } + camel_operation_end(NULL); } closedir(dir); @@ -682,8 +715,12 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange if (camel_local_summary_check(cls, changes, ex) == -1) return -1; + camel_operation_start(NULL, _("Storing folder")); + count = camel_folder_summary_count((CamelFolderSummary *)cls); for (i=count-1;i>=0;i--) { + camel_operation_progress(NULL, (count-i)*100/count); + info = camel_folder_summary_index((CamelFolderSummary *)cls, i); mdi = (CamelMaildirMessageInfo *)info; if (info && (info->flags & CAMEL_MESSAGE_DELETED) && expunge) { @@ -693,7 +730,7 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange /* FIXME: put this in folder_summary::remove()? */ if (cls->index) - ibex_unindex(cls->index, (char *)camel_message_info_uid(info)); + camel_index_delete_name(cls->index, camel_message_info_uid(info)); camel_folder_change_info_remove_uid(changes, camel_message_info_uid(info)); camel_folder_summary_remove((CamelFolderSummary *)cls, info); @@ -748,6 +785,8 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange camel_folder_summary_info_free((CamelFolderSummary *)cls, info); } + camel_operation_end(NULL); + return ((CamelLocalSummaryClass *)parent_class)->sync(cls, expunge, changes, ex); } |