Changeset 4162 in subversion
- Timestamp:
- Oct 29, 2010 2:02:19 PM (3 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (4 diffs)
-
program/include/rcube_imap_generic.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r4160 r4162 58 58 - Plugin API: add possibility to disable plugin in framed mode, 'noframe' property 59 59 - Improve performance of setting IMAP flags using .SILENT suffix 60 - Improve performance of message cache status checking with skip_disabled=true 60 61 61 62 RELEASE 0.4.2 -
trunk/roundcubemail/program/include/rcube_imap.php
r4161 r4162 547 547 $search_str .= " UNSEEN"; 548 548 } 549 else if ($status) { 550 $keys[] = 'MAX'; 551 $need_uid = true; 549 else { 550 if ($this->caching_enabled) { 551 $keys[] = 'ALL'; 552 } 553 if ($status) { 554 $keys[] = 'MAX'; 555 $need_uid = true; 556 } 552 557 } 553 558 … … 558 563 $count = is_array($index) ? $index['COUNT'] : 0; 559 564 560 if ($mode == 'ALL' && $status) { 561 $this->set_folder_stats($mailbox, 'cnt', $count); 562 $this->set_folder_stats($mailbox, 'maxuid', is_array($index) ? $index['MAX'] : 0); 565 if ($mode == 'ALL') { 566 if ($need_uid && $this->caching_enabled) { 567 // Save messages index for check_cache_status() 568 $this->icache['all_undeleted_idx'] = $index['ALL']; 569 } 570 if ($status) { 571 $this->set_folder_stats($mailbox, 'cnt', $count); 572 $this->set_folder_stats($mailbox, 'maxuid', is_array($index) ? $index['MAX'] : 0); 573 } 563 574 } 564 575 } … … 3647 3658 3648 3659 // empty mailbox 3649 if (!$msg_count) 3660 if (!$msg_count) { 3650 3661 return $cache_count ? -2 : 1; 3662 } 3651 3663 3652 3664 if ($cache_count == $msg_count) { 3653 3665 if ($this->skip_deleted) { 3654 $h_index = $this->conn->fetchHeaderIndex($mailbox, "1:*", 'UID', $this->skip_deleted); 3655 3656 // Save index in internal cache, will be used when syncing the cache 3657 $this->icache['folder_index'] = $h_index; 3658 3659 if (empty($h_index)) 3660 return -2; 3661 3662 if (sizeof($h_index) == $cache_count) { 3663 $cache_index = array_flip($cache_index); 3664 foreach ($h_index as $idx => $uid) 3665 unset($cache_index[$uid]); 3666 3667 if (empty($cache_index)) 3668 return 1; 3669 } 3670 return -2; 3666 if (!empty($this->icache['all_undeleted_idx'])) { 3667 $uids = rcube_imap_generic::uncompressMessageSet($this->icache['all_undeleted_idx']); 3668 $uids = array_flip($uids); 3669 foreach ($cache_index as $uid) { 3670 unset($uids[$uid]); 3671 } 3672 } 3673 else { 3674 // get all undeleted messages excluding cached UIDs 3675 $uids = $this->search_once($mailbox, 'ALL UNDELETED NOT UID '. 3676 rcube_imap_generic::compressMessageSet($cache_index)); 3677 } 3678 if (empty($uids)) { 3679 return 1; 3680 } 3671 3681 } else { 3672 3682 // get UID of the message with highest index … … 3675 3685 3676 3686 // uids of highest message matches -> cache seems OK 3677 if ($cache_uid == $uid) 3687 if ($cache_uid == $uid) { 3678 3688 return 1; 3689 } 3679 3690 } 3680 3691 // cache is dirty 3681 3692 return -1; 3682 3693 } 3694 3683 3695 // if cache count differs less than 10% report as dirty 3684 else if (abs($msg_count - $cache_count) < $msg_count/10) 3685 return -1; 3686 else 3687 return -2; 3696 return (abs($msg_count - $cache_count) < $msg_count/10) ? -1 : -2; 3688 3697 } 3689 3698 -
trunk/roundcubemail/program/include/rcube_imap_generic.php
r4161 r4162 1009 1009 1010 1010 // message IDs 1011 if ( is_array($add))1012 $add = $this->compressMessageSet( join(',', $add));1011 if (!empty($add)) 1012 $add = $this->compressMessageSet($add); 1013 1013 1014 1014 list($code, $response) = $this->execute($is_uid ? 'UID SORT' : 'SORT', … … 1027 1027 { 1028 1028 if (is_array($message_set)) { 1029 if (!($message_set = $this->compressMessageSet( join(',', $message_set))))1029 if (!($message_set = $this->compressMessageSet($message_set))) 1030 1030 return false; 1031 1031 } else { … … 1151 1151 } 1152 1152 1153 privatefunction compressMessageSet($messages, $force=false)1153 static function compressMessageSet($messages, $force=false) 1154 1154 { 1155 1155 // given a comma delimited list of independent mid's, 1156 1156 // compresses by grouping sequences together 1157 1157 1158 if (!is_array($message _set)) {1158 if (!is_array($messages)) { 1159 1159 // if less than 255 bytes long, let's not bother 1160 1160 if (!$force && strlen($messages)<255) { … … 1200 1200 } 1201 1201 1202 static function uncompressMessageSet($messages) 1203 { 1204 $result = array(); 1205 $messages = explode(',', $messages); 1206 1207 foreach ($messages as $part) { 1208 $items = explode(':', $part); 1209 $max = max($items[0], $items[1]); 1210 1211 for ($x=$items[0]; $x<=$max; $x++) { 1212 $result[] = $x; 1213 } 1214 } 1215 1216 return $result; 1217 } 1218 1202 1219 /** 1203 1220 * Returns message sequence identifier … … 1265 1282 return false; 1266 1283 } 1267 1268 if (is_array($message_set))1269 $message_set = join(',', $message_set);1270 1284 1271 1285 $message_set = $this->compressMessageSet($message_set); … … 1825 1839 $result['MAX'] = !empty($response) ? max($response) : 0; 1826 1840 if (in_array('ALL', $items)) 1827 $result['ALL'] = $this->compressMessageSet( implode(',', $response), true);1841 $result['ALL'] = $this->compressMessageSet($response, true); 1828 1842 1829 1843 return $result;
Note: See TracChangeset
for help on using the changeset viewer.
