summaryrefslogtreecommitdiff
path: root/lib/kolab_sync_data_email.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-08-25 16:10:34 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-08-25 16:10:34 (GMT)
commitbde4a2325ca38726a47e7c9069505df8e1a15e95 (patch)
treef1f24cf63011e8a91306bfb46fc41bef472b16c9 /lib/kolab_sync_data_email.php
parent813c7becb7f561e5af6c5ed2641703bf66235059 (diff)
downloadkolab-syncroton-bde4a2325ca38726a47e7c9069505df8e1a15e95.tar.gz
Fix various issues in email flags change detection and synchronization
Diffstat (limited to 'lib/kolab_sync_data_email.php')
-rw-r--r--lib/kolab_sync_data_email.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/kolab_sync_data_email.php b/lib/kolab_sync_data_email.php
index 4fb436a..5b2268e 100644
--- a/lib/kolab_sync_data_email.php
+++ b/lib/kolab_sync_data_email.php
@@ -779,11 +779,12 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
// convert filter into one IMAP search string
foreach ($filter as $idx => $filter_item) {
if (is_array($filter_item)) {
- // This is a request for changes since list time
+ // This is a request for changes since last time
// we'll use HIGHESTMODSEQ value from the last Sync
if ($filter_item[0] == 'changed' && $filter_item[1] == '>') {
- $modseq = (array) $this->backend->modseq_get($this->device->id, $folderid, $filter_item[2]);
- $modseq_data = array();
+ $modseq_lasttime = $filter_item[2];
+ $modseq_data = array();
+ $modseq = (array) $this->backend->modseq_get($this->device->id, $folderid, $modseq_lasttime);
}
}
else {
@@ -795,6 +796,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
// no sorting for best performance
$sort_by = null;
$found = 0;
+ $ts = time();
foreach ($folders as $folder_id) {
$foldername = $this->backend->folder_id2name($folder_id, $this->device->deviceid);
@@ -807,16 +809,13 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$this->storage->set_folder($foldername);
- // Syncronize folder (if it wasn't synced in this request already)
- if ($this->lastsync_folder != $foldername
- || $this->lastsync_time < time() - Syncroton_Registry::getPingTimeout()
+ // Synchronize folder (if it wasn't synced in this request already)
+ if ($this->lastsync_folder != $folderid
+ || $this->lastsync_time <= $ts - Syncroton_Registry::getPingTimeout()
) {
$this->storage->folder_sync($foldername);
}
- $this->lastsync_folder = $foldername;
- $this->lastsync_time = time();
-
// We're in "get changes" mode
if (isset($modseq_data)) {
$folder_data = $this->storage->folder_data($foldername);
@@ -879,9 +878,19 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
throw new Syncroton_Exception_Status(Syncroton_Exception_Status::SERVER_ERROR);
}
+ $this->lastsync_folder = $folderid;
+ $this->lastsync_time = $ts;
+
if (!empty($modseq_update)) {
$this->backend->modseq_set($this->device->id, $folderid,
$this->syncTimeStamp, $modseq_data);
+
+ // if previous modseq information does not exist save current set as it,
+ // we would at least be able to detect changes since now
+ if (empty($result) && empty($modseq)) {
+ $this->backend->modseq_set($this->device->id, $folderid,
+ $modseq_lasttime, $modseq_data);
+ }
}
return $result;