Optimize folder_size() on Cyrus IMAP by using special folder annotation (#1490514)

pull/294/head
Aleksander Machniak 9 years ago
parent 5eb9c70b60
commit 427ab2f393

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Optimize folder_size() on Cyrus IMAP by using special folder annotation (#1490514)
- Make optional hidding of folders with name starting with a dot - imap_skip_hidden_folders (#1490468)
- Add option to enable HTML editor always, except when replying to plain text messages (#1489365)
- Emoticons: Added option to switch on/off emoticons in compose editor (#1485732)

@ -3112,10 +3112,24 @@ class rcube_imap extends rcube_storage
*/
public function folder_size($folder)
{
if (!strlen($folder)) {
return false;
}
if (!$this->check_connection()) {
return 0;
}
// On Cyrus we can use special folder annotation, which should be much faster
if ($this->get_vendor() == 'cyrus') {
$idx = '/shared/vendor/cmu/cyrus-imapd/size';
$result = $this->get_metadata($folder, $idx, array(), true);
if (!empty($result) && is_numeric($result[$folder][$idx])) {
return $result[$folder][$idx];
}
}
// @TODO: could we try to use QUOTA here?
$result = $this->conn->fetchHeaderIndex($folder, '1:*', 'SIZE', false);
@ -3882,14 +3896,16 @@ class rcube_imap extends rcube_storage
* @param string $folder Folder name (empty for server metadata)
* @param array $entries Entries
* @param array $options Command options (with MAXSIZE and DEPTH keys)
* @param bool $force Disables cache use
*
* @return array Metadata entry-value hash array on success, NULL on error
* @since 0.5-beta
*/
public function get_metadata($folder, $entries, $options=array())
public function get_metadata($folder, $entries, $options = array(), $force = false)
{
$entries = (array) $entries;
if (!$force) {
// create cache key
// @TODO: this is the simplest solution, but we do the same with folders list
// maybe we should store data per-entry and merge on request
@ -3904,6 +3920,7 @@ class rcube_imap extends rcube_storage
if (is_array($cached_data)) {
return $cached_data;
}
}
if (!$this->check_connection()) {
return null;
@ -3941,7 +3958,10 @@ class rcube_imap extends rcube_storage
}
if (isset($res)) {
if (!$force) {
$this->update_cache($cache_key, $res);
}
return $res;
}

@ -945,10 +945,11 @@ abstract class rcube_storage
* @param string $folder Folder name (empty for server metadata)
* @param array $entries Entries
* @param array $options Command options (with MAXSIZE and DEPTH keys)
* @param bool $force Disables cache use
*
* @return array Metadata entry-value hash array on success, NULL on error
*/
abstract function get_metadata($folder, $entries, $options = array());
abstract function get_metadata($folder, $entries, $options = array(), $force = false);
/* -----------------------------------------
* Cache related functions

Loading…
Cancel
Save