--- /home/dwmw2/git/evolution-data-server-2.30/camel/providers/imapx/camel-imapx-server.c	2010-06-17 00:13:34.431649697 +0100
+++ camel-imapx-server.c	2010-06-17 02:54:35.232226303 +0100
@@ -1684,6 +1684,7 @@ imapx_command_status_done (CamelIMAPXSer
 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) ic->job->folder;
 
 	ifolder->unread_on_server = is->unread;
+	ifolder->exists_on_server = is->exists;
 	e_flag_set (ic->flag);
 }
 
@@ -3296,11 +3297,11 @@ imapx_job_refresh_info_start (CamelIMAPX
 
 	/* Check if a rescan is needed */
 	total = camel_folder_summary_count (folder->summary);
-	if (ifolder->exists_on_server == total) {
+	if (!ifolder->exists_on_server || ifolder->exists_on_server == total) {
 		guint32 unread;
 		CamelIMAPXCommand *ic;
 
-		ic = camel_imapx_command_new ("STATUS", folder->full_name, "STATUS %f (MESSAGES UNSEEN)", folder);
+		ic = camel_imapx_command_new ("STATUS", NULL, "STATUS %f (MESSAGES UNSEEN)", folder);
 		ic->job = job;
 		ic->pri = job->pri;
 		ic->complete = imapx_command_status_done;
@@ -3322,9 +3323,15 @@ imapx_job_refresh_info_start (CamelIMAPX
 			goto exception;
 	}
 
-	imapx_job_scan_changes_start (is, job);
-	return;
-
+	if (ifolder->exists_on_server) {
+		imapx_job_scan_changes_start (is, job);
+		return;
+	} else {
+		/* We know there are no messages on the server -- we checked. */
+		while (total)
+			camel_folder_summary_remove_index(folder->summary, --total);
+	}
+		
 exception:
 	imapx_job_done (is, job);
 }
