Changeset 0e11940 in github


Ignore:
Timestamp:
Dec 6, 2010 9:06:44 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
d7e83d3
Parents:
7472893
Message:
  • Improve performance of folder rename and delete actions. Don't get list of all folders when we need only children of the specified folder.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r7472893 r0e11940  
    1616- Improve performance of moving or copying of all messages in a folder 
    1717- Fix plaintext versions of HTML messages don't contain placeholders for emotions (#1485206) 
     18- Improve performance of folder rename and delete actions 
    1819 
    1920RELEASE 0.5-BETA 
  • program/include/rcube_imap.php

    r9e81b55 r0e11940  
    30193019     * Get mailbox size (size of all messages in a mailbox) 
    30203020     * 
    3021      * @param string $name Mailbox name     
     3021     * @param string $name Mailbox name 
    30223022     * @return int Mailbox size in bytes, False on error 
    30233023     */ 
     
    30943094     * @param string $mbox_name Mailbox to rename 
    30953095     * @param string $new_name  New mailbox name 
     3096     * 
    30963097     * @return boolean True on success 
    30973098     */ 
     
    31033104        $mailbox  = $this->mod_mailbox($mbox_name); 
    31043105        $abs_name = $this->mod_mailbox($new_name); 
    3105  
    3106         // check if mailbox is subscribed 
    3107         $a_subscribed = $this->_list_mailboxes(); 
    3108         $subscribed   = in_array($mailbox, $a_subscribed); 
    3109  
    3110         // unsubscribe folder 
    3111         if ($subscribed) 
    3112             $this->conn->unsubscribe($mailbox); 
     3106        $delm     = $this->get_hierarchy_delimiter(); 
     3107 
     3108        // get list of subscribed folders 
     3109        if ((strpos($mailbox, '%') === false) && (strpos($mailbox, '*') === false)) { 
     3110            $a_subscribed = $this->_list_mailboxes('', $mbox_name . $delm . '*'); 
     3111            $subscribed   = $this->mailbox_exists($mbox_name, true); 
     3112        } 
     3113        else { 
     3114            $a_subscribed = $this->_list_mailboxes(); 
     3115            $subscribed   = in_array($mailbox, $a_subscribed); 
     3116        } 
    31133117 
    31143118        if (strlen($abs_name)) 
     
    31163120 
    31173121        if ($result) { 
    3118             $delm = $this->get_hierarchy_delimiter(); 
     3122            // unsubscribe the old folder, subscribe the new one 
     3123            if ($subscribed) { 
     3124                $this->conn->unsubscribe($mailbox); 
     3125                $this->conn->subscribe($abs_name); 
     3126            } 
    31193127 
    31203128            // check if mailbox children are subscribed 
    3121             foreach ($a_subscribed as $c_subscribed) 
     3129            foreach ($a_subscribed as $c_subscribed) { 
    31223130                if (preg_match('/^'.preg_quote($mailbox.$delm, '/').'/', $c_subscribed)) { 
    31233131                    $this->conn->unsubscribe($c_subscribed); 
     
    31253133                        $abs_name, $c_subscribed)); 
    31263134                } 
     3135            } 
    31273136 
    31283137            // clear cache 
     
    31313140        } 
    31323141 
    3133         // try to subscribe it 
    3134         if ($result && $subscribed) 
    3135             $this->conn->subscribe($abs_name); 
    3136  
    31373142        return $result; 
    31383143    } 
     
    31403145 
    31413146    /** 
    3142      * Remove mailboxes from server 
    3143      * 
    3144      * @param string|array $mbox_name Mailbox name(s) string/array 
     3147     * Remove mailbox from server 
     3148     * 
     3149     * @param string $mbox_name Mailbox name 
     3150     * 
    31453151     * @return boolean True on success 
    31463152     */ 
    31473153    function delete_mailbox($mbox_name) 
    31483154    { 
    3149         $deleted = false; 
    3150  
    3151         if (is_array($mbox_name)) 
    3152             $a_mboxes = $mbox_name; 
    3153         else if (is_string($mbox_name) && strlen($mbox_name)) 
    3154             $a_mboxes = explode(',', $mbox_name); 
    3155  
    3156         if (is_array($a_mboxes)) { 
    3157             $delimiter = $this->get_hierarchy_delimiter(); 
    3158          
    3159             foreach ($a_mboxes as $mbox_name) { 
    3160                 $mailbox = $this->mod_mailbox($mbox_name); 
    3161                 $sub_mboxes = $this->conn->listMailboxes('', $mbox_name . $delimiter . '*'); 
    3162  
    3163                 // unsubscribe mailbox before deleting 
    3164                 $this->conn->unsubscribe($mailbox); 
    3165  
    3166                 // send delete command to server 
    3167                 $result = $this->conn->deleteFolder($mailbox); 
    3168                 if ($result) { 
    3169                     $deleted = true; 
    3170                     $this->clear_message_cache($mailbox.'.msg'); 
    3171                     } 
    3172  
    3173                 foreach ($sub_mboxes as $c_mbox) { 
    3174                     if ($c_mbox != 'INBOX') { 
    3175                         $this->conn->unsubscribe($c_mbox); 
    3176                         $result = $this->conn->deleteFolder($c_mbox); 
    3177                         if ($result) { 
    3178                             $deleted = true; 
    3179                             $this->clear_message_cache($c_mbox.'.msg'); 
    3180                         } 
     3155        $result  = false; 
     3156        $mailbox = $this->mod_mailbox($mbox_name); 
     3157        $delm    = $this->get_hierarchy_delimiter(); 
     3158 
     3159        // get list of folders 
     3160        if ((strpos($mailbox, '%') === false) && (strpos($mailbox, '*') === false)) 
     3161            $sub_mboxes = $this->list_unsubscribed('', $mailbox . $delm . '*'); 
     3162        else 
     3163            $sub_mboxes = $this->list_unsubscribed(); 
     3164 
     3165        // send delete command to server 
     3166        $result = $this->conn->deleteFolder($mailbox); 
     3167 
     3168        if ($result) { 
     3169            // unsubscribe mailbox 
     3170            $this->conn->unsubscribe($mailbox); 
     3171 
     3172            foreach ($sub_mboxes as $c_mbox) { 
     3173                if (preg_match('/^'.preg_quote($mailbox.$delm, '/').'/', $c_mbox)) { 
     3174                    $this->conn->unsubscribe($c_mbox); 
     3175                    if ($this->conn->deleteFolder($c_mbox)) { 
     3176                            $this->clear_message_cache($c_mbox.'.msg'); 
    31813177                    } 
    31823178                } 
    31833179            } 
    3184         } 
    3185  
    3186         // clear mailboxlist cache 
    3187         if ($deleted) 
     3180 
     3181            // clear mailbox-related cache 
     3182            $this->clear_message_cache($mailbox.'.msg'); 
    31883183            $this->clear_cache('mailboxes'); 
    3189  
    3190         return $deleted; 
     3184        } 
     3185 
     3186        return $result; 
    31913187    } 
    31923188 
  • program/steps/settings/folders.inc

    raf3c045e r0e11940  
    6666else if ($RCMAIL->action == 'delete-folder') 
    6767{ 
    68     $a_mboxes  = $IMAP->list_unsubscribed(); 
    69     $delimiter = $IMAP->get_hierarchy_delimiter(); 
    70    
    7168    $mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true); 
    7269    $mbox      = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP'); 
    7370 
     71    // get folder's children or all folders if the name contains special characters 
     72    $delimiter = $IMAP->get_hierarchy_delimiter(); 
     73    if ((strpos($mbox, '%') === false) && (strpos($mbox, '*') === false)) 
     74        $a_mboxes  = $IMAP->list_unsubscribed('', $mbox.$delimiter.'*'); 
     75    else 
     76        $a_mboxes  = $IMAP->list_unsubscribed(); 
     77 
    7478    if (strlen($mbox)) 
    75         $deleted = $IMAP->delete_mailbox(array($mbox)); 
     79        $deleted = $IMAP->delete_mailbox($mbox); 
    7680 
    7781    if ($OUTPUT->ajax_call && $deleted) { 
    78         // Remove folder rows 
     82        // Remove folder and subfolders rows 
    7983        $OUTPUT->command('remove_folder_row', $mbox_utf8); 
    8084        foreach ($a_mboxes as $folder) { 
     
    122126 
    123127                $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF7-IMAP') : false; 
    124          
     128 
    125129                $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF7-IMAP'), 
    126130                    rcube_charset_convert($folderlist[$x], 'UTF7-IMAP'), $display_rename, $before); 
Note: See TracChangeset for help on using the changeset viewer.