summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2013-10-07 13:57:55 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2013-10-07 13:57:55 (GMT)
commit71619510c49633527c66de8ca2d98c06a71c4c35 (patch)
tree7e137f546f5fc189ce5c1e150dbc2de38b763080
parent9d174daf9f98e8e60cddf77cf1416e42470ba77b (diff)
downloadroundcubemail-plugins-kolab-71619510c49633527c66de8ca2d98c06a71c4c35.tar.gz
Improve bypass() method so it works "recursively"
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 0e30dfa..1165631 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -99,16 +99,16 @@ class kolab_storage_cache
// lock synchronization for this folder or wait if locked
$this->_sync_lock();
- // synchronize IMAP mailbox cache
+ // disable messages cache if configured to do so
$this->bypass(true);
+
+ // synchronize IMAP mailbox cache
$this->imap->folder_sync($this->folder->name);
// compare IMAP index with object cache index
$imap_index = $this->imap->index($this->folder->name);
$this->index = $imap_index->get();
- $this->bypass(false);
-
// determine objects to fetch or to invalidate
if ($this->ready) {
// read cache index
@@ -143,6 +143,8 @@ class kolab_storage_cache
}
}
+ $this->bypass(false);
+
// remove lock
$this->_sync_unlock();
@@ -813,11 +815,25 @@ class kolab_storage_cache
}
if ($messages_cache) {
+ // handle recurrent (multilevel) bypass() calls
+ if ($disable) {
+ $this->cache_bypassed += 1;
+ if ($this->cache_bypassed > 1) {
+ return;
+ }
+ }
+ else {
+ $this->cache_bypassed -= 1;
+ if ($this->cache_bypassed > 0) {
+ return;
+ }
+ }
+
switch ($cache_bypass) {
case 2:
// Disable messages cache completely
$this->imap->set_messages_caching(!$disable);
- return;
+ break;
case 1:
// We'll disable messages cache, but keep index cache.