diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/folder.c | 2 | ||||
-rw-r--r-- | src/folder.h | 2 | ||||
-rw-r--r-- | src/imap.c | 6 | ||||
-rw-r--r-- | src/mh.c | 13 | ||||
-rw-r--r-- | src/news.c | 7 | ||||
-rw-r--r-- | src/procmsg.c | 5 | ||||
-rw-r--r-- | src/summaryview.c | 45 |
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; @@ -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; } @@ -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; } @@ -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) |