aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-05-27 10:57:37 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-05-27 10:57:37 +0000
commit0c58540309726e0e476d90ca9d488142a58b4fcd (patch)
treee66d05f06fe02ba193f1a63a69bcaee8dc8c6596
parent2ddb31bb4cf51711d786e1a994f2a91ed80e7cee (diff)
optimized the writing of mark file.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@293 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog12
-rw-r--r--ChangeLog.ja13
-rw-r--r--src/compose.c2
-rw-r--r--src/folder.c1
-rw-r--r--src/folder.h1
-rw-r--r--src/imap.c39
-rw-r--r--src/mh.c3
-rw-r--r--src/news.c5
-rw-r--r--src/procmsg.c7
-rw-r--r--src/summaryview.c45
10 files changed, 105 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index fa97ef1a..8f196852 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2005-05-27
+ * src/mh.c
+ src/compose.c
+ src/folder.[ch]
+ src/imap.c
+ src/procmsg.c
+ src/news.c
+ src/summaryview.c: added FolderItem::mark_dirty flag to determine
+ if mark file really needs to be updated.
+ Write mark file only if cache_dirty or mark_dirty flag is set.
+
+2005-05-27
+
* src/imap.c: don't destroy the previous Session object when
reconnecting (fixed crash when reconnection happened while scanning
tree).
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 3a5e491f..484e96e8 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,18 @@
2005-05-27
+ * src/mh.c
+ src/compose.c
+ src/folder.[ch]
+ src/imap.c
+ src/procmsg.c
+ src/news.c
+ src/summaryview.c: FolderItem::mark_dirty を追加し、マークファイル
+ を本当に更新する必要があるかどうかを判断するようにした。
+ cache_dirty または mark_dirty フラグが立っている場合のみマーク
+ ファイルを書き出すようにした。
+
+2005-05-27
+
* src/imap.c: 再接続時に以前の Session オブジェクトを破壊しないように
した(ツリーのスキャン時に再接続が発生したときにクラッシュするのを
修正)。
diff --git a/src/compose.c b/src/compose.c
index c6eebe64..905ff16c 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -716,6 +716,7 @@ void compose_reply(MsgInfo *msginfo, FolderItem *item, ComposeMode mode,
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
+ msginfo->folder->mark_dirty = TRUE;
if (MSG_IS_IMAP(msginfo->flags))
imap_msg_set_perm_flags(msginfo, MSG_REPLIED);
@@ -791,6 +792,7 @@ void compose_forward(GSList *mlist, FolderItem *item, gboolean as_attach,
msginfo = (MsgInfo *)cur->data;
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
+ msginfo->folder->mark_dirty = TRUE;
}
msginfo = (MsgInfo *)mlist->data;
if (MSG_IS_IMAP(msginfo->flags))
diff --git a/src/folder.c b/src/folder.c
index 7d45dec1..7dadc35a 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -175,6 +175,7 @@ FolderItem *folder_item_new(const gchar *name, const gchar *path)
item->opened = FALSE;
item->updated = FALSE;
item->cache_dirty = FALSE;
+ item->mark_dirty = FALSE;
item->node = NULL;
item->parent = NULL;
item->folder = NULL;
diff --git a/src/folder.h b/src/folder.h
index 66497704..0d241a13 100644
--- a/src/folder.h
+++ b/src/folder.h
@@ -256,6 +256,7 @@ struct _FolderItem
guint updated : 1; /* folderview should be updated */
guint cache_dirty : 1; /* cache file needs to be updated */
+ guint mark_dirty : 1; /* mark file needs to be updated */
FolderSortKey sort_key;
FolderSortType sort_type;
diff --git a/src/imap.c b/src/imap.c
index 50e09611..f3a6ecfe 100644
--- a/src/imap.c
+++ b/src/imap.c
@@ -926,6 +926,7 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
mlist = g_slist_remove(mlist, msginfo);
procmsg_msginfo_free(msginfo);
item->cache_dirty = TRUE;
+ item->mark_dirty = TRUE;
continue;
}
@@ -934,27 +935,46 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
item->unread++;
MSG_SET_PERM_FLAGS(msginfo->flags,
MSG_UNREAD);
+ item->mark_dirty = TRUE;
}
} else {
- if (MSG_IS_NEW(msginfo->flags))
+ if (MSG_IS_NEW(msginfo->flags)) {
item->new--;
- if (MSG_IS_UNREAD(msginfo->flags))
+ item->mark_dirty = TRUE;
+ }
+ if (MSG_IS_UNREAD(msginfo->flags)) {
item->unread--;
+ item->mark_dirty = TRUE;
+ }
MSG_UNSET_PERM_FLAGS(msginfo->flags,
MSG_NEW|MSG_UNREAD);
}
if (IMAP_IS_FLAGGED(imap_flags)) {
- MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+ if (!MSG_IS_MARKED(msginfo->flags)) {
+ MSG_SET_PERM_FLAGS(msginfo->flags,
+ MSG_MARKED);
+ item->mark_dirty = TRUE;
+ }
} else {
- MSG_UNSET_PERM_FLAGS(msginfo->flags,
- MSG_MARKED);
+ if (MSG_IS_MARKED(msginfo->flags)) {
+ MSG_UNSET_PERM_FLAGS(msginfo->flags,
+ MSG_MARKED);
+ item->mark_dirty = TRUE;
+ }
}
if (IMAP_IS_ANSWERED(imap_flags)) {
- MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
+ if (!MSG_IS_REPLIED(msginfo->flags)) {
+ MSG_SET_PERM_FLAGS(msginfo->flags,
+ MSG_REPLIED);
+ item->mark_dirty = TRUE;
+ }
} else {
- MSG_UNSET_PERM_FLAGS(msginfo->flags,
- MSG_REPLIED);
+ if (MSG_IS_REPLIED(msginfo->flags)) {
+ MSG_UNSET_PERM_FLAGS(msginfo->flags,
+ MSG_REPLIED);
+ item->mark_dirty = TRUE;
+ }
}
}
@@ -1015,7 +1035,8 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
item->last_num = last_uid;
- debug_print("cache_dirty: %d\n", item->cache_dirty);
+ debug_print("cache_dirty: %d, mark_dirty: %d\n",
+ item->cache_dirty, item->mark_dirty);
catch:
return mlist;
diff --git a/src/mh.c b/src/mh.c
index afe2e462..489a8fa6 100644
--- a/src/mh.c
+++ b/src/mh.c
@@ -239,7 +239,8 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
g_print("mh_get_msg_list: %s: elapsed time: %ld.%06ld sec\n",
item->path, tv_result.tv_sec, tv_result.tv_usec);
#endif
- debug_print("cache_dirty: %d\n", item->cache_dirty);
+ debug_print("cache_dirty: %d, mark_dirty: %d\n",
+ item->cache_dirty, item->mark_dirty);
return mlist;
}
diff --git a/src/news.c b/src/news.c
index 1ea76502..2c045ca9 100644
--- a/src/news.c
+++ b/src/news.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -344,7 +344,8 @@ static GSList *news_get_article_list(Folder *folder, FolderItem *item,
alist = procmsg_sort_msg_list(alist, item->sort_key, item->sort_type);
- debug_print("cache_dirty: %d\n", item->cache_dirty);
+ debug_print("cache_dirty: %d, mark_dirty: %d\n",
+ item->cache_dirty, item->mark_dirty);
return alist;
}
diff --git a/src/procmsg.c b/src/procmsg.c
index 0dc17a16..c97d7b02 100644
--- a/src/procmsg.c
+++ b/src/procmsg.c
@@ -328,6 +328,7 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
if (!mark_table) {
item->new = item->unread = item->total = g_slist_length(mlist);
item->updated = TRUE;
+ item->mark_dirty = TRUE;
return;
}
@@ -340,6 +341,7 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
if (!flags) {
g_hash_table_foreach(mark_table,
mark_unset_new_func, NULL);
+ item->mark_dirty = TRUE;
break;
}
}
@@ -382,6 +384,9 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item)
item->last_num = lastnum;
item->updated = TRUE;
+ if (unflagged > 0)
+ item->mark_dirty = TRUE;
+
debug_print("new: %d unread: %d unflagged: %d total: %d\n",
new, unread, unflagged, total);
@@ -628,6 +633,7 @@ static GHashTable *procmsg_read_mark_file(FolderItem *item)
if (item->mark_queue) {
g_hash_table_foreach(mark_table, mark_unset_new_func, NULL);
+ item->mark_dirty = TRUE;
}
for (cur = item->mark_queue; cur != NULL; cur = cur->next) {
@@ -650,6 +656,7 @@ static GHashTable *procmsg_read_mark_file(FolderItem *item)
procmsg_write_mark_file(item, mark_table);
procmsg_msg_list_free(item->mark_queue);
item->mark_queue = NULL;
+ item->mark_dirty = FALSE;
}
return mark_table;
diff --git a/src/summaryview.c b/src/summaryview.c
index 262c04f3..df6dd770 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -1964,7 +1964,8 @@ static gboolean summary_write_cache_func(GtkTreeModel *model,
if (fps->cache_fp)
procmsg_write_cache(msginfo, fps->cache_fp);
- procmsg_write_flags(msginfo, fps->mark_fp);
+ if (fps->mark_fp)
+ procmsg_write_flags(msginfo, fps->mark_fp);
return FALSE;
}
@@ -1978,19 +1979,28 @@ gint summary_write_cache(SummaryView *summaryview)
item = summaryview->folder_item;
if (!item || !item->path)
return -1;
+ if (item->mark_queue)
+ item->mark_dirty = TRUE;
+ if (!item->cache_dirty && !item->mark_dirty)
+ return 0;
if (item->cache_dirty) {
fps.cache_fp = procmsg_open_cache_file(item, DATA_WRITE);
if (fps.cache_fp == NULL)
return -1;
+ item->mark_dirty = TRUE;
} else
fps.cache_fp = NULL;
- fps.mark_fp = procmsg_open_mark_file(item, DATA_WRITE);
- if (fps.mark_fp == NULL) {
- if (fps.cache_fp)
- fclose(fps.cache_fp);
- return -1;
- }
+
+ if (item->mark_dirty) {
+ fps.mark_fp = procmsg_open_mark_file(item, DATA_WRITE);
+ if (fps.mark_fp == NULL) {
+ if (fps.cache_fp)
+ fclose(fps.cache_fp);
+ return -1;
+ }
+ } else
+ fps.mark_fp = NULL;
if (item->cache_dirty) {
buf = g_strdup_printf(_("Writing summary cache (%s)..."),
@@ -2004,12 +2014,15 @@ gint summary_write_cache(SummaryView *summaryview)
gtk_tree_model_foreach(GTK_TREE_MODEL(summaryview->store),
summary_write_cache_func, &fps);
- procmsg_flush_mark_queue(item, fps.mark_fp);
+ if (item->mark_queue)
+ procmsg_flush_mark_queue(item, fps.mark_fp);
+
item->unmarked_num = 0;
if (fps.cache_fp)
fclose(fps.cache_fp);
- fclose(fps.mark_fp);
+ if (fps.mark_fp)
+ fclose(fps.mark_fp);
debug_print(_("done.\n"));
@@ -2017,7 +2030,7 @@ gint summary_write_cache(SummaryView *summaryview)
STATUSBAR_POP(summaryview->mainwin);
}
- item->cache_dirty = FALSE;
+ item->cache_dirty = item->mark_dirty = FALSE;
return 0;
}
@@ -2116,9 +2129,11 @@ static void summary_display_msg_full(SummaryView *summaryview,
summaryview->folder_item->new--;
if (MSG_IS_UNREAD(msginfo->flags))
summaryview->folder_item->unread--;
- if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
+ if (MSG_IS_NEW(msginfo->flags) ||
+ MSG_IS_UNREAD(msginfo->flags)) {
MSG_UNSET_PERM_FLAGS
(msginfo->flags, MSG_NEW | MSG_UNREAD);
+ summaryview->folder_item->mark_dirty = TRUE;
if (MSG_IS_IMAP(msginfo->flags))
imap_msg_unset_perm_flags
(msginfo, MSG_NEW | MSG_UNREAD);
@@ -2293,6 +2308,7 @@ static void summary_mark_row(SummaryView *summaryview, GtkTreeIter *iter)
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+ summaryview->folder_item->mark_dirty = TRUE;
summary_set_row(summaryview, iter, msginfo);
debug_print(_("Message %d is marked\n"), msginfo->msgnum);
@@ -2338,6 +2354,7 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
summaryview->folder_item->unread--;
if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
+ summaryview->folder_item->mark_dirty = TRUE;
summary_set_row(summaryview, iter, msginfo);
debug_print(_("Message %d is marked as being read\n"),
msginfo->msgnum);
@@ -2407,11 +2424,13 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
msginfo->to_folder = NULL;
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
summaryview->deleted--;
+ summaryview->folder_item->mark_dirty = TRUE;
}
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED | MSG_FORWARDED);
if (!MSG_IS_UNREAD(msginfo->flags)) {
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
summaryview->folder_item->unread++;
+ summaryview->folder_item->mark_dirty = TRUE;
debug_print(_("Message %d is marked as unread\n"),
msginfo->msgnum);
}
@@ -2462,6 +2481,7 @@ static void summary_delete_row(SummaryView *summaryview, GtkTreeIter *iter)
MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
MSG_SET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
summaryview->deleted++;
+ summaryview->folder_item->mark_dirty = TRUE;
if (!prefs_common.immediate_exec &&
summaryview->folder_item->stype != F_TRASH)
@@ -2586,6 +2606,7 @@ static void summary_unmark_row(SummaryView *summaryview, GtkTreeIter *iter)
summaryview->copied--;
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
+ summaryview->folder_item->mark_dirty = TRUE;
summary_set_row(summaryview, iter, msginfo);
debug_print(_("Message %s/%d is unmarked\n"),
@@ -2637,6 +2658,7 @@ static void summary_move_row_to(SummaryView *summaryview, GtkTreeIter *iter,
MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
summaryview->moved++;
}
+ summaryview->folder_item->mark_dirty = TRUE;
if (!prefs_common.immediate_exec)
summary_set_row(summaryview, iter, msginfo);
@@ -2710,6 +2732,7 @@ static void summary_copy_row_to(SummaryView *summaryview, GtkTreeIter *iter,
MSG_SET_TMP_FLAGS(msginfo->flags, MSG_COPY);
summaryview->copied++;
}
+ summaryview->folder_item->mark_dirty = TRUE;
if (!prefs_common.immediate_exec)
summary_set_row(summaryview, iter, msginfo);