Thomas Bruederli
2014-06-04 3412e50b54e3daac8745234e21ab6e72be0ed165
program/lib/Roundcube/rcube_imap.php
@@ -1513,6 +1513,16 @@
            $this->threading = false;
            $searcher = new rcube_imap_search($this->options, $this->conn);
            // set limit to not exceed the client's request timeout
            $searcher->set_timelimit(60);
            // continue existing incomplete search
            if (!empty($this->search_set) && $this->search_set->incomplete && $str == $this->search_string) {
                $searcher->set_results($this->search_set);
            }
            // execute the search
            $results = $searcher->exec(
                $folder,
                $str,
@@ -1702,6 +1712,19 @@
        }
        return $this->get_search_set();
    }
    /**
     * Flag certain result subsets as 'incomplete'.
     * For subsequent refresh_search() calls to only refresh the updated parts.
     */
    protected function set_search_dirty($folder)
    {
        if ($this->search_set && is_a($this->search_set, 'rcube_result_multifolder')) {
            if ($subset = $this->search_set->get_set($folder)) {
                $subset->incomplete = $this->search_set->incomplete = true;
            }
        }
    }
@@ -2410,6 +2433,8 @@
                    $this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
                }
            }
            $this->set_search_dirty($folder);
        }
        return $result;
@@ -2519,6 +2544,9 @@
        if ($moved) {
            $this->clear_messagecount($from_mbox);
            $this->clear_messagecount($to_mbox);
            $this->set_search_dirty($from_mbox);
            $this->set_search_dirty($to_mbox);
        }
        // moving failed
        else if ($to_trash && $config->get('delete_always', false)) {
@@ -2535,7 +2563,7 @@
                if ($this->search_threads || $all_mode) {
                    $this->refresh_search();
                }
                else {
                else if (!$this->search_set->incomplete) {
                    $this->search_set->filter(explode(',', $uids), $this->folder);
                }
            }
@@ -2623,13 +2651,15 @@
            // unset threads internal cache
            unset($this->icache['threads']);
            $this->set_search_dirty($folder);
            // remove message ids from search set
            if ($this->search_set && $folder == $this->folder) {
                // threads are too complicated to just remove messages from set
                if ($this->search_threads || $all_mode) {
                    $this->refresh_search();
                }
                else {
                else if (!$this->search_set->incomplete) {
                    $this->search_set->filter(explode(',', $uids));
                }
            }