From e232acbfde30e27101f84da7f0a617f8a8522512 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 03 Dec 2010 07:25:49 -0500
Subject: [PATCH] - Improve performance of moving or copying of all messages in a folder (use CLOSE intead of EXPUNGE) - Code cleanup + added more phpdoc comments

---
 program/include/rcube_imap.php |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index dd9f81b..bf88c29 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -185,7 +185,7 @@
      */
     function close()
     {
-        $this->conn->close();
+        $this->conn->closeConnection();
         $this->write_cache();
     }
 
@@ -198,7 +198,7 @@
      */
     function reconnect()
     {
-        $this->close();
+        $this->closeConnection();
         $this->connect($this->host, $this->user, $this->pass, $this->port, $this->ssl);
 
         // issue SELECT command to restore connection status
@@ -617,7 +617,7 @@
         }
         // RECENT count is fetched a bit different
         else if ($mode == 'RECENT') {
-            $count = $this->conn->checkForRecent($mailbox);
+            $count = $this->conn->countRecent($mailbox);
         }
         // use SEARCH for message counting
         else if ($this->skip_deleted) {
@@ -2582,6 +2582,7 @@
 
         // send expunge command in order to have the moved message
         // really deleted from the source mailbox
+$aa = rcube_timer();
         if ($moved) {
             $this->_expunge($from_mbox, false, $uids);
             $this->_clear_messagecount($from_mbox);
@@ -2591,7 +2592,7 @@
         else if ($config->get('delete_always', false) && $tbox == $config->get('trash_mbox')) {
             $moved = $this->delete_message($uids, $fbox);
         }
-
+rcube_print_time($aa);
         if ($moved) {
             // unset threads internal cache
             unset($this->icache['threads']);
@@ -2774,7 +2775,11 @@
         else
             $a_uids = NULL;
 
-        $result = $this->conn->expunge($mailbox, $a_uids);
+        // CLOSE(+SELECT) should be faster than EXPUNGE
+        if (empty($a_uids) || $a_uids == '1:*')
+            $result = $this->conn->close();
+        else
+            $result = $this->conn->expunge($mailbox, $a_uids);
 
         if ($result && $clear_cache) {
             $this->clear_message_cache($mailbox.'.msg');

--
Gitblit v1.9.1