aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/folder.c2
-rw-r--r--src/folder.h2
-rw-r--r--src/imap.c6
-rw-r--r--src/mh.c13
-rw-r--r--src/news.c7
-rw-r--r--src/procmsg.c5
-rw-r--r--src/summaryview.c45
7 files changed, 62 insertions, 18 deletions
diff --git a/src/folder.c b/src/folder.c
index d89d72d2..7d45dec1 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -173,6 +173,8 @@ FolderItem *folder_item_new(const gchar *name, const gchar *path)
item->collapsed = FALSE;
item->threaded = TRUE;
item->opened = FALSE;
+ item->updated = FALSE;
+ item->cache_dirty = FALSE;
item->node = NULL;
item->parent = NULL;
item->folder = NULL;
diff --git a/src/folder.h b/src/folder.h
index 5b397878..66497704 100644
--- a/src/folder.h
+++ b/src/folder.h
@@ -255,6 +255,8 @@ struct _FolderItem
guint opened : 1; /* opened by summary view */
guint updated : 1; /* folderview should be updated */
+ guint cache_dirty : 1; /* cache file needs to be updated */
+
FolderSortKey sort_key;
FolderSortType sort_type;
diff --git a/src/imap.c b/src/imap.c
index 5dfb806d..dec32a70 100644
--- a/src/imap.c
+++ b/src/imap.c
@@ -888,6 +888,7 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
item->total--;
mlist = g_slist_remove(mlist, msginfo);
procmsg_msginfo_free(msginfo);
+ item->cache_dirty = TRUE;
continue;
}
@@ -960,12 +961,15 @@ static GSList *imap_get_msg_list(Folder *folder, FolderItem *item,
newlist = imap_get_uncached_messages(session, item,
begin, last_uid,
TRUE);
+ if (newlist)
+ item->cache_dirty = TRUE;
mlist = g_slist_concat(mlist, newlist);
}
} else {
imap_delete_all_cached_messages(item);
mlist = imap_get_uncached_messages(session, item, 0, 0, TRUE);
last_uid = procmsg_get_last_num_in_msg_list(mlist);
+ item->cache_dirty = TRUE;
}
item->mtime = uid_validity;
@@ -974,6 +978,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);
+
catch:
return mlist;
}
diff --git a/src/mh.c b/src/mh.c
index 97825646..afe2e462 100644
--- a/src/mh.c
+++ b/src/mh.c
@@ -204,21 +204,27 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item,
if (use_cache && item->mtime == cur_mtime) {
debug_print("Folder is not modified.\n");
mlist = procmsg_read_cache(item, FALSE);
- if (!mlist)
+ if (!mlist) {
mlist = mh_get_uncached_msgs(NULL, item);
+ if (mlist)
+ item->cache_dirty = TRUE;
+ }
} else if (use_cache) {
GSList *newlist;
mlist = procmsg_read_cache(item, TRUE);
msg_table = procmsg_msg_hash_table_create(mlist);
-
newlist = mh_get_uncached_msgs(msg_table, item);
+ if (newlist)
+ item->cache_dirty = TRUE;
if (msg_table)
g_hash_table_destroy(msg_table);
mlist = g_slist_concat(mlist, newlist);
- } else
+ } else {
mlist = mh_get_uncached_msgs(NULL, item);
+ item->cache_dirty = TRUE;
+ }
item->mtime = cur_mtime;
@@ -233,6 +239,7 @@ 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);
return mlist;
}
diff --git a/src/news.c b/src/news.c
index c65f803c..1ea76502 100644
--- a/src/news.c
+++ b/src/news.c
@@ -315,10 +315,13 @@ static GSList *news_get_article_list(Folder *folder, FolderItem *item,
cache_last = procmsg_get_last_num_in_msg_list(alist);
newlist = news_get_uncached_articles
(session, item, cache_last, &first, &last);
+ if (newlist)
+ item->cache_dirty = TRUE;
if (first == 0 && last == 0) {
news_delete_all_articles(item);
procmsg_msg_list_free(alist);
alist = NULL;
+ item->cache_dirty = TRUE;
} else {
alist = news_delete_old_articles(alist, item, first);
news_delete_expired_caches(alist, item);
@@ -334,12 +337,15 @@ static GSList *news_get_article_list(Folder *folder, FolderItem *item,
(session, item, 0, NULL, &last);
news_delete_all_articles(item);
item->last_num = last;
+ item->cache_dirty = TRUE;
}
procmsg_set_flags(alist, item);
alist = procmsg_sort_msg_list(alist, item->sort_key, item->sort_type);
+ debug_print("cache_dirty: %d\n", item->cache_dirty);
+
return alist;
}
@@ -1014,6 +1020,7 @@ static GSList *news_delete_old_articles(GSList *alist, FolderItem *item,
if (msginfo && msginfo->msgnum < first) {
procmsg_msginfo_free(msginfo);
alist = g_slist_remove(alist, msginfo);
+ item->cache_dirty = TRUE;
}
cur = next;
diff --git a/src/procmsg.c b/src/procmsg.c
index 1a12f096..0dc17a16 100644
--- a/src/procmsg.c
+++ b/src/procmsg.c
@@ -277,9 +277,10 @@ GSList *procmsg_read_cache(FolderItem *item, gboolean scan_file)
/* if the message file doesn't exist or is changed,
don't add the data */
if ((type == F_MH && scan_file &&
- folder_item_is_msg_changed(item, msginfo)) || num == 0)
+ folder_item_is_msg_changed(item, msginfo)) || num == 0) {
procmsg_msginfo_free(msginfo);
- else {
+ item->cache_dirty = TRUE;
+ } else {
msginfo->folder = item;
if (!mlist)
diff --git a/src/summaryview.c b/src/summaryview.c
index 756a77a6..75d27b01 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -1955,7 +1955,8 @@ static gboolean summary_write_cache_func(GtkTreeModel *model,
MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW);
}
- procmsg_write_cache(msginfo, fps->cache_fp);
+ if (fps->cache_fp)
+ procmsg_write_cache(msginfo, fps->cache_fp);
procmsg_write_flags(msginfo, fps->mark_fp);
return FALSE;
@@ -1971,20 +1972,27 @@ gint summary_write_cache(SummaryView *summaryview)
if (!item || !item->path)
return -1;
- fps.cache_fp = procmsg_open_cache_file(item, DATA_WRITE);
- if (fps.cache_fp == NULL)
- return -1;
+ if (item->cache_dirty) {
+ fps.cache_fp = procmsg_open_cache_file(item, DATA_WRITE);
+ if (fps.cache_fp == NULL)
+ return -1;
+ } else
+ fps.cache_fp = NULL;
fps.mark_fp = procmsg_open_mark_file(item, DATA_WRITE);
if (fps.mark_fp == NULL) {
- fclose(fps.cache_fp);
+ if (fps.cache_fp)
+ fclose(fps.cache_fp);
return -1;
}
- buf = g_strdup_printf(_("Writing summary cache (%s)..."), item->path);
- debug_print(buf);
- STATUSBAR_PUSH(summaryview->mainwin, buf);
- gdk_flush();
- g_free(buf);
+ if (item->cache_dirty) {
+ buf = g_strdup_printf(_("Writing summary cache (%s)..."),
+ item->path);
+ debug_print(buf);
+ STATUSBAR_PUSH(summaryview->mainwin, buf);
+ gdk_flush();
+ g_free(buf);
+ }
gtk_tree_model_foreach(GTK_TREE_MODEL(summaryview->store),
summary_write_cache_func, &fps);
@@ -1992,11 +2000,17 @@ gint summary_write_cache(SummaryView *summaryview)
procmsg_flush_mark_queue(item, fps.mark_fp);
item->unmarked_num = 0;
- fclose(fps.cache_fp);
+ if (fps.cache_fp)
+ fclose(fps.cache_fp);
fclose(fps.mark_fp);
debug_print(_("done.\n"));
- STATUSBAR_POP(summaryview->mainwin);
+
+ if (item->cache_dirty) {
+ STATUSBAR_POP(summaryview->mainwin);
+ }
+
+ item->cache_dirty = FALSE;
return 0;
}
@@ -2914,6 +2928,7 @@ static void summary_remove_invalid_messages(SummaryView *summaryview)
{
GtkTreeModel *model = GTK_TREE_MODEL(summaryview->store);
MsgInfo *disp_msginfo = NULL, *msginfo;
+ FolderItem *item = summaryview->folder_item;
GtkTreeIter iter, next;
GtkTreePath *path;
gboolean valid;
@@ -2940,7 +2955,7 @@ static void summary_remove_invalid_messages(SummaryView *summaryview)
}
}
- if (summaryview->folder_item->threaded)
+ if (item->threaded)
summary_modify_threads(summaryview);
/* update selection */
@@ -2990,6 +3005,8 @@ static void summary_remove_invalid_messages(SummaryView *summaryview)
gtk_tree_store_remove(GTK_TREE_STORE(model), &iter);
procmsg_msginfo_free(msginfo);
+
+ item->cache_dirty = TRUE;
}
if (summaryview->displayed &&
@@ -3442,6 +3459,8 @@ static void summary_modify_node(SummaryView *summaryview, GtkTreeIter *iter,
g_node_destroy(root);
gtk_tree_store_remove(GTK_TREE_STORE(model), iter);
+
+ summaryview->folder_item->cache_dirty = TRUE;
}
static void summary_modify_threads(SummaryView *summaryview)