Branch 'libkolab-cache-bypass' - plugins/libkolab

Aleksander Machniak machniak at kolabsys.com
Mon Oct 7 15:59:08 CEST 2013


 plugins/libkolab/lib/kolab_storage_cache.php |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 71619510c49633527c66de8ca2d98c06a71c4c35
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Mon Oct 7 15:57:55 2013 +0200

    Improve bypass() method so it works "recursively"

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.




More information about the commits mailing list