Aleksander Machniak
2015-09-02 427ab2f3938122d7ce1d0862a583a5adaed6c6c9
program/lib/Roundcube/rcube_imap.php
@@ -3112,8 +3112,22 @@
     */
    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?
@@ -3882,14 +3896,16 @@
     * @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
@@ -3903,6 +3919,7 @@
        if (is_array($cached_data)) {
            return $cached_data;
            }
        }
        if (!$this->check_connection()) {
@@ -3941,7 +3958,10 @@
        }
        if (isset($res)) {
            if (!$force) {
            $this->update_cache($cache_key, $res);
            }
            return $res;
        }