Remove the copy-paste that was folder[view]_fast_scan_tree, and
authorColin Leroy <colin@colino.net>
Wed, 30 Apr 2014 19:34:53 +0000 (21:34 +0200)
committerColin Leroy <colin@colino.net>
Wed, 30 Apr 2014 19:34:53 +0000 (21:34 +0200)
instead fix folder_scan_tree to do the right thing when called
in "Check for new folders" mode: Don't rescan the contents of
all folders after having updated the list of folders. There's
"Check for new messages" for that.
Fixes bug #2119, "Check for new folders on remote mailboxes
is very slow".

src/folder.c
src/folder.h
src/folderview.c
src/folderview.h
src/imap_gtk.c

index a248abc..6fa6d78 100644 (file)
@@ -903,13 +903,23 @@ static gboolean folder_scan_tree_func(GNode *node, gpointer data)
 {
        GHashTable *pptable = (GHashTable *)data;
        FolderItem *item = (FolderItem *)node->data;
-       
+
        folder_item_restore_persist_prefs(item, pptable);
        folder_item_scan_full(item, FALSE);
 
        return FALSE;
 }
 
+static gboolean folder_restore_prefs_func(GNode *node, gpointer data)
+{
+       GHashTable *pptable = (GHashTable *)data;
+       FolderItem *item = (FolderItem *)node->data;
+
+       folder_item_restore_persist_prefs(item, pptable);
+
+       return FALSE;
+}
+
 void folder_scan_tree(Folder *folder, gboolean rebuild)
 {
        GHashTable *pptable;
@@ -936,44 +946,11 @@ void folder_scan_tree(Folder *folder, gboolean rebuild)
        hookdata.item = NULL;
        hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
 
-       g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_scan_tree_func, pptable);
-       folder_persist_prefs_free(pptable);
-
-       prefs_matcher_read_config();
-
-       folder_write_list();
-}
-
-static gboolean folder_restore_prefs_func(GNode *node, gpointer data)
-{
-       GHashTable *pptable = (GHashTable *)data;
-       FolderItem *item = (FolderItem *)node->data;
-       
-       folder_item_restore_persist_prefs(item, pptable);
-
-       return FALSE;
-}
-
-void folder_fast_scan_tree(Folder *folder)
-{
-       GHashTable *pptable;
-       FolderUpdateData hookdata;
-
-       if (!folder->klass->scan_tree)
-               return;
-       
-       pptable = folder_persist_prefs_new(folder);
-
-       if (folder->klass->scan_tree(folder) < 0) {
-               return;
-       } 
-
-       hookdata.folder = folder;
-       hookdata.update_flags = FOLDER_TREE_CHANGED;
-       hookdata.item = NULL;
-       hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
+       if (rebuild)
+               g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_scan_tree_func, pptable);
+       else
+               g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_restore_prefs_func, pptable);
 
-       g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_restore_prefs_func, pptable);
        folder_persist_prefs_free(pptable);
 
        prefs_matcher_read_config();
index 191dcd8..6ba032d 100644 (file)
@@ -854,7 +854,6 @@ GList *folder_get_list              (void);
 gint   folder_read_list                (void);
 void   folder_write_list       (void);
 void   folder_scan_tree                (Folder *folder, gboolean rebuild);
-void   folder_fast_scan_tree   (Folder *folder);
 FolderItem *folder_create_folder(FolderItem    *parent, const gchar *name);
 gint   folder_item_rename      (FolderItem *item, gchar *newname);
 void   folder_update_op_count          (void);
index abbc1de..42a0c86 100644 (file)
@@ -1086,47 +1086,6 @@ void folderview_rescan_tree(Folder *folder, gboolean rebuild)
        inc_unlock();
 }
 
-void folderview_fast_rescan_tree(Folder *folder)
-{
-       GtkWidget *window;
-       MainWindow *mainwin = mainwindow_get_mainwindow();
-       FolderView *folderview = NULL;
-       GtkAdjustment *pos = NULL;
-       gint height = 0;
-
-       cm_return_if_fail(folder != NULL);
-
-       if (!folder->klass->scan_tree) return;
-
-       inc_lock();
-
-       window = label_window_create(_("Scanning folder tree..."));
-
-       if (mainwin)
-               folderview = mainwin->folderview;
-       
-       if (folderview) {
-               pos = gtk_scrolled_window_get_vadjustment(
-                                       GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-               height = gtk_adjustment_get_value(pos);
-       }
-
-       folder_set_ui_func(folder, folderview_scan_tree_func, NULL);
-       folder_fast_scan_tree(folder);
-       folder_set_ui_func(folder, NULL, NULL);
-
-       folderview_set_all();
-
-       if (folderview) {
-               pos = gtk_scrolled_window_get_vadjustment(
-                                       GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-               gtk_adjustment_set_value(pos, height);
-               gtk_adjustment_changed(pos);
-       }
-       label_window_destroy(window);
-       inc_unlock();
-}
-
 /** folderview_check_new()
  *  Scan and update the folder and return the 
  *  count the number of new messages since last check. 
index aa6a4c3..c6f524e 100644 (file)
@@ -121,7 +121,6 @@ FolderItem *folderview_get_selected_item(FolderView *folderview);
 
 void folderview_rescan_tree            (Folder         *folder,
                                         gboolean        rebuild);
-void folderview_fast_rescan_tree       (Folder         *folder);
 gint folderview_check_new              (Folder         *folder);
 void folderview_check_new_all          (void);
 
index dae79e1..dcda56e 100644 (file)
@@ -552,7 +552,7 @@ static void subscribe_cb_full(FolderView *folderview, guint action)
                        for (cur = transc_list; cur; cur = cur->next) 
                                g_free((gchar *)cur->data);
                        if (r == 0)
-                               folderview_fast_rescan_tree(item->folder);
+                               folderview_rescan_tree(item->folder, FALSE);
                } else {
                        alertpanel_notice(_("This folder is already subscribed and "
                                  "has no unsubscribed subfolders.\n\nIf there are new folders, "
@@ -596,7 +596,7 @@ static void subscribe_cb_full(FolderView *folderview, guint action)
        }
 
        if (!action && item->folder->account->imap_subsonly)
-               folderview_fast_rescan_tree(item->folder);
+               folderview_rescan_tree(item->folder, FALSE);
 }
 
 static void subscribe_cb(GtkAction *action, gpointer data)
@@ -629,7 +629,7 @@ static void subscribed_cb(GtkAction *action, gpointer data)
        }
 
        item->folder->account->imap_subsonly = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-       folderview_fast_rescan_tree(item->folder);
+       folderview_rescan_tree(item->folder, FALSE);
 }
 
 static void download_cb(GtkAction *action, gpointer data)