if (item->no_select)
return -1;
+ if (item->scanning) {
+ debug_print("%s is scanning... \n", item->path ? item->path : item->name);
+ return -2;
+ }
+
item->processing_pending = TRUE;
folder_item_process_open (item, NULL, NULL, NULL);
g_return_val_if_fail(folder != NULL, -1);
g_return_val_if_fail(folder->klass->get_num_list != NULL, -1);
+ item->scanning = TRUE;
+
debug_print("Scanning folder %s for cache changes.\n", item->path ? item->path : "(null)");
/* Get list of messages for folder and cache */
if (folder->klass->get_num_list(item->folder, item, &folder_list, &old_uids_valid) < 0) {
debug_print("Error fetching list of message numbers\n");
+ item->scanning = FALSE;
return(-1);
}
folder_item_update(item, update_flags);
folder_item_update_thaw();
+ item->scanning = FALSE;
+
return 0;
}
if (item->no_select)
return -1;
+ item->scanning = TRUE;
+
if (item->cache == NULL)
folder_item_read_cache(item);
g_slist_free(msglist);
+ item->scanning = FALSE;
+
return ret;
}
if (folder && folder != item->folder) continue;
if (!folder && !FOLDER_IS_LOCAL(item->folder)) continue;
if (!item->prefs->newmailcheck) continue;
-
+ if (item->processing_pending == TRUE) {
+ debug_print("skipping %s, processing pending\n",
+ item->path ? item->path : item->name);
+ continue;
+ }
+
str = get_scan_str(item);
STATUSBAR_PUSH(folderview->mainwin, str);
return FALSE;
}
+typedef struct _PostponedSelectData
+{
+ GtkCTree *ctree;
+ GtkCTreeNode *row;
+ gint column;
+ FolderView *folderview;
+} PostponedSelectData;
+
+static gboolean postpone_select(void *data)
+{
+ PostponedSelectData *psdata = (PostponedSelectData *)data;
+ debug_print("trying again\n");
+ psdata->folderview->open_folder = TRUE;
+ main_window_cursor_normal(psdata->folderview->mainwin);
+ STATUSBAR_POP(psdata->folderview->mainwin);
+ folderview_selected(psdata->ctree, psdata->row,
+ psdata->column, psdata->folderview);
+ g_free(psdata);
+ return FALSE;
+}
+
static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
gint column, FolderView *folderview)
{
gboolean opened;
FolderItem *item;
gchar *buf;
+ int res = 0;
folderview->selected = row;
main_window_cursor_wait(folderview->mainwin);
- if (folder_item_open(item) != 0) {
+ res = folder_item_open(item);
+ if (res == -1) {
main_window_cursor_normal(folderview->mainwin);
STATUSBAR_POP(folderview->mainwin);
can_select = TRUE;
return;
- }
+ } else if (res == -2) {
+ PostponedSelectData *data = g_new0(PostponedSelectData, 1);
+ data->ctree = ctree;
+ data->row = row;
+ data->column = column;
+ data->folderview = folderview;
+ debug_print("postponing open of %s till end of scan\n",
+ item->path ? item->path:item->name);
+ folderview->open_folder = FALSE;
+ can_select = TRUE;
+ g_timeout_add(500, postpone_select, data);
+ return;
+ }
main_window_cursor_normal(folderview->mainwin);