Support RFC8438: IMAP STATUS=SIZE - for faster folder size calculation (#7269)

pull/7282/head
Aleksander Machniak 4 years ago
parent 088714619e
commit d194b238c7

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Support RFC8438: IMAP STATUS=SIZE - for faster folder size calculation (#7269)
- MySQL: Use utf8mb4 charset and utf8mb4_unicode_ci collation (#6535, #7113)
- Support for language codes up to 16 chars long (e.g. es-419) in database schema (#6851)
- Relaxed domain name validation for extended TLDs support (#5588)

@ -370,9 +370,9 @@ class rcube_imap extends rcube_storage
/**
* Returns the IMAP server's capability.
*
* @param string $cap Capability name
* @param string $cap Capability name
*
* @return mixed Capability value or TRUE if supported, FALSE if not
* @return mixed Capability value or TRUE if supported, FALSE if not
*/
public function get_capability($cap)
{
@ -3181,6 +3181,13 @@ class rcube_imap extends rcube_storage
return 0;
}
if ($this->get_capability('STATUS=SIZE')) {
$status = $this->conn->status($folder, array('SIZE'));
if (is_array($status) && array_key_exists('SIZE', $status)) {
return (int) $status['SIZE'];
}
}
// 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';

@ -1526,7 +1526,7 @@ class rcube_imap_generic
if (!empty($return_opts) && $this->getCapability('LIST-STATUS')) {
$lstatus = true;
$status_opts = array('MESSAGES', 'RECENT', 'UIDNEXT', 'UIDVALIDITY', 'UNSEEN');
$status_opts = array('MESSAGES', 'RECENT', 'UIDNEXT', 'UIDVALIDITY', 'UNSEEN', 'SIZE');
$opts = array_diff($return_opts, $status_opts);
$status_opts = array_diff($return_opts, $opts);

@ -237,13 +237,22 @@ function rcmail_folder_form($attrib)
if ((!$options['noselect'] && !$options['is_root']) || $mbox == 'INBOX') {
$msgcount = $storage->count($mbox, 'ALL', true, false);
// Size
if ($msgcount) {
// Get the size on servers with supposed-to-be-fast method for that
if ($storage->get_capability('STATUS=SIZE')) {
$size = $storage->folder_size($mbox);
if ($size !== false) {
$size = $RCMAIL->show_bytes($size);
}
}
// create link with folder-size command
$onclick = sprintf("return %s.command('folder-size', '%s', this)",
rcmail_output::JS_OBJECT_NAME, rcube::JQ($mbox));
$size = html::a(array('href' => '#', 'onclick' => $onclick,
'id' => 'folder-size'), $RCMAIL->gettext('getfoldersize'));
if (!isset($size) || $size === false) {
$onclick = sprintf("return %s.command('folder-size', '%s', this)",
rcmail_output::JS_OBJECT_NAME, rcube::JQ($mbox));
$size = html::a(array('href' => '#', 'onclick' => $onclick,
'id' => 'folder-size'), $RCMAIL->gettext('getfoldersize'));
}
}
else {
// no messages -> zero size

Loading…
Cancel
Save