Changes of Revision 83

roundcubemail-plugins-kolab.spec Changed
x
 
1
@@ -62,7 +62,6 @@
2
 Source104:      plesk.libkolab.inc.php
3
 
4
 Patch0000:      roundcubemail-plugins-kolab-3.4-kolab-files-manticore-api.patch
5
-Patch0001:      0001-Fix-kolab-cache-sync-issues.patch
6
 
7
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
8
 BuildArch:      noarch
9
@@ -1398,7 +1397,6 @@
10
 cp -av %{datadir}/skins/elastic/styles/ skins/elastic/. || :
11
 
12
 %patch0000 -p1
13
-%patch0001 -p1
14
 
15
 %if 0%{?plesk}
16
 # Provide defaults for Plesk
17
0001-Fix-kolab-cache-sync-issues.patch Deleted
201
 
1
@@ -1,537 +0,0 @@
2
-From 23c76d2ef80b35acf8d86ae4e4391020918998cf Mon Sep 17 00:00:00 2001
3
-From: Aleksander Machniak <machniak@kolabsys.com>
4
-Date: Fri, 16 Oct 2020 11:01:12 +0200
5
-Subject: PATCH Fix kolab cache sync issues
6
-
7
-Summary: Use QRESYNC, get rid of "scheduled" cache reset, other small improvements
8
-
9
-Reviewers: #roundcube_kolab_plugins_developers
10
-
11
-Subscribers: #roundcube_kolab_plugins_developers
12
-
13
-Differential Revision: https://git.kolab.org/D1726
14
----
15
- plugins/libkolab/config.inc.php.dist         |   4 -
16
- plugins/libkolab/lib/kolab_storage_cache.php | 404 ++++++++++++++-----
17
- 2 files changed, 295 insertions(+), 113 deletions(-)
18
-
19
-diff --git a/plugins/libkolab/config.inc.php.dist b/plugins/libkolab/config.inc.php.dist
20
-index 81f4ea80..9801af37 100644
21
---- a/plugins/libkolab/config.inc.php.dist
22
-+++ b/plugins/libkolab/config.inc.php.dist
23
-@@ -5,10 +5,6 @@
24
- // Enable caching of Kolab objects in local database
25
- $config'kolab_cache' = true;
26
- 
27
--// Cache refresh interval (default is 12 hours)
28
--// after this period, cache is forced to synchronize with IMAP
29
--$config'kolab_cache_refresh' = '12h';
30
--
31
- // Specify format version to write Kolab objects (must be a string value!)
32
- $config'kolab_format_version'  = '3.0';
33
- 
34
-diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
35
-index 8f682e54..18b5e5f2 100644
36
---- a/plugins/libkolab/lib/kolab_storage_cache.php
37
-+++ b/plugins/libkolab/lib/kolab_storage_cache.php
38
-@@ -27,8 +27,6 @@ class kolab_storage_cache
39
-     const DB_DATE_FORMAT = 'Y-m-d H:i:s';
40
-     const MAX_RECORDS    = 500;
41
- 
42
--    public $sync_complete = false;
43
--
44
-     protected $db;
45
-     protected $imap;
46
-     protected $folder;
47
-@@ -42,7 +40,6 @@ class kolab_storage_cache
48
-     protected $synclock = false;
49
-     protected $ready = false;
50
-     protected $cache_table;
51
--    protected $cache_refresh = 3600;
52
-     protected $folders_table;
53
-     protected $max_sql_packet;
54
-     protected $max_sync_lock_time = 600;
55
-@@ -85,7 +82,6 @@ class kolab_storage_cache
56
-         $this->imap = $rcmail->get_storage();
57
-         $this->enabled = $rcmail->config->get('kolab_cache', false);
58
-         $this->folders_table = $this->db->table_name('kolab_folders');
59
--        $this->cache_refresh = get_offset_sec($rcmail->config->get('kolab_cache_refresh', '12h'));
60
-         $this->server_timezone = new DateTimeZone(date_default_timezone_get());
61
- 
62
-         if ($this->enabled) {
63
-@@ -174,16 +170,6 @@ class kolab_storage_cache
64
-         if ($this->synched)
65
-             return;
66
- 
67
--        // increase time limit
68
--        @set_time_limit($this->max_sync_lock_time - 60);
69
--
70
--        // get effective time limit we have for synchronization (~70% of the execution time)
71
--        $time_limit = ini_get('max_execution_time') * 0.7;
72
--        $sync_start = time();
73
--
74
--        // assume sync will be completed
75
--        $this->sync_complete = true;
76
--
77
-         if (!$this->ready) {
78
-             // kolab cache is disabled, synchronize IMAP mailbox cache only
79
-             $this->imap_mode(true);
80
-@@ -191,124 +177,312 @@ class kolab_storage_cache
81
-             $this->imap_mode(false);
82
-         }
83
-         else {
84
-+            $this->sync_start = time();
85
-+
86
-             // read cached folder metadata
87
-             $this->_read_folder_data();
88
- 
89
-+            // Read folder data from IMAP
90
-+            $ctag = $this->folder->get_ctag();
91
-+
92
-+            // Validate current ctag
93
-+            list($uidvalidity, $highestmodseq, $uidnext) = explode('-', $ctag);
94
-+
95
-+            if (empty($uidvalidity) || empty($highestmodseq)) {
96
-+                rcube::raise_error(array(
97
-+                    'code' => 900,
98
-+                    'message' => "Failed to sync the kolab cache (Invalid ctag)"
99
-+                ), true);
100
-+            }
101
-             // check cache status ($this->metadata is set in _read_folder_data())
102
--            if (  empty($this->metadata'ctag') ||
103
--                  empty($this->metadata'changed') ||
104
--                  $this->metadata'objectcount' === null ||
105
--                  $this->metadata'changed' < date(self::DB_DATE_FORMAT, time() - $this->cache_refresh) ||
106
--                  $this->metadata'ctag' != $this->folder->get_ctag() ||
107
--                  intval($this->metadata'objectcount') !== $this->count()
108
-+            else if (
109
-+                empty($this->metadata'ctag')
110
-+                || empty($this->metadata'changed')
111
-+                || $this->metadata'ctag' !== $ctag
112
-             ) {
113
-                 // lock synchronization for this folder or wait if locked
114
-                 $this->_sync_lock();
115
- 
116
--                // disable messages cache if configured to do so
117
--                $this->imap_mode(true);
118
-+                // Run a full-sync (initial sync or continue the aborted sync)
119
-+                if (empty($this->metadata'changed') || empty($this->metadata'ctag')) {
120
-+                    $result = $this->synchronize_full();
121
-+                }
122
-+                // Synchronize only the changes since last sync
123
-+                else {
124
-+                    $result = $this->synchronize_update($ctag);
125
-+                }
126
-+
127
-+                // update ctag value (will be written to database in _sync_unlock())
128
-+                if ($result) {
129
-+                    $this->metadata'ctag'    = $ctag;
130
-+                    $this->metadata'changed' = date(self::DB_DATE_FORMAT, time());
131
-+                }
132
-+
133
-+                // remove lock
134
-+                $this->_sync_unlock();
135
-+            }
136
-+        }
137
- 
138
--                // synchronize IMAP mailbox cache
139
--                $this->imap->folder_sync($this->folder->name);
140
-+        $this->check_error();
141
-+        $this->synched = time();
142
-+    }
143
- 
144
--                // compare IMAP index with object cache index
145
--                $imap_index = $this->imap->index($this->folder->name, null, null, true, true);
146
-+    /**
147
-+     * Perform full cache synchronization
148
-+     */
149
-+    protected function synchronize_full()
150
-+    {
151
-+        // get effective time limit we have for synchronization (~70% of the execution time)
152
-+        $time_limit = $this->_max_sync_lock_time() * 0.7;
153
- 
154
--                $this->imap_mode(false);
155
-+        if (time() - $this->sync_start > $time_limit) {
156
-+            return false;
157
-+        }
158
- 
159
--                // determine objects to fetch or to invalidate
160
--                if (!$imap_index->is_error()) {
161
--                    $imap_index = $imap_index->get();
162
--                    $old_index  = array();
163
--                    $del_index  = array();
164
-+        // disable messages cache if configured to do so
165
-+        $this->imap_mode(true);
166
- 
167
--                    // read cache index
168
--                    $sql_result = $this->db->query(
169
--                        "SELECT `msguid`, `uid` FROM `{$this->cache_table}` WHERE `folder_id` = ?"
170
--                            . " ORDER BY `msguid` DESC", $this->folder_id
171
--                    );
172
-+        // synchronize IMAP mailbox cache, does nothing if messages cache is disabled
173
-+        $this->imap->folder_sync($this->folder->name);
174
- 
175
--                    while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
176
--                        // Mark all duplicates for removal (note sorting order above)
177
--                        // Duplicates here should not happen, but they do sometimes
178
--                        if (isset($old_index$sql_arr'uid')) {
179
--                            $del_index = $sql_arr'msguid';
180
--                        }
181
--                        else {
182
--                            $old_index$sql_arr'uid' = $sql_arr'msguid';
183
--                        }
184
--                    }
185
-+        // compare IMAP index with object cache index
186
-+        $imap_index = $this->imap->index($this->folder->name, null, null, true, true);
187
- 
188
--                    // fetch new objects from imap
189
--                    $i = 0;
190
--                    foreach (array_diff($imap_index, $old_index) as $msguid) {
191
--                        // Note: We'll store only objects matching the folder type
192
--                        // anything else will be silently ignored
193
--                        if ($object = $this->folder->read_object($msguid)) {
194
--                            // Deduplication: remove older objects with the same UID
195
--                            // Here we do not resolve conflicts, we just make sure
196
--                            // the most recent version of the object will be used
197
--                            if ($old_msguid = $old_index$object'uid') {
198
--                                if ($old_msguid < $msguid) {
199
--                                    $del_index = $old_msguid;
200
--                                }
201
debian.series Changed
4
 
1
@@ -1,2 +1,1 @@
2
 roundcubemail-plugins-kolab-3.4-kolab-files-manticore-api.patch -p1
3
-0001-Fix-kolab-cache-sync-issues.patch -p1
4