2 commits - lib/ext lib/kolab_sync_backend.php lib/kolab_sync_data.php
Aleksander Machniak
machniak at kolabsys.com
Thu Jan 17 14:33:01 CET 2013
lib/ext/Syncroton/Command/Sync.php | 2 +-
lib/ext/Syncroton/Data/AData.php | 4 ++--
lib/ext/Syncroton/Data/IData.php | 2 +-
lib/kolab_sync_backend.php | 5 +++--
lib/kolab_sync_data.php | 21 +++++++++++++--------
5 files changed, 20 insertions(+), 14 deletions(-)
New commits:
commit 3345011cf30084ffc29350fff3339858e8f03ca9
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Jan 17 14:32:30 2013 +0100
Small perf improvement to the last changes
diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index 7424a32..108f6d3 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -748,13 +748,14 @@ class kolab_sync_backend
0, 2, $deviceid, $folderid, $synctime);
if ($row = $db->fetch_assoc()) {
+ $current = $row['synctime'];
$this->modseq[$deviceid][$folderid][$synctime] = json_decode($row['data']);
// Cleanup: remove old records (older than 12 hours from the last one)
- if ($row = $db->fetch_assoc()) {
+ if (($row = $db->fetch_assoc()) && $row['synctime'] < $current - 86400) {
$db->query("DELETE FROM syncroton_modseq"
." WHERE device_id = ? AND folder_id = ? AND synctime < ?",
- $deviceid, $folderid, $row['synctime'] - 86400);
+ $deviceid, $folderid, $current - 86400);
}
}
}
commit caf489c1e35f32c27d61abbe981a01f3848fc9ed
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Jan 17 14:29:27 2013 +0100
Make changes detection aware of FilterType - don't return changes for
objects that don't match current (last) filter + fix some small bugs
diff --git a/lib/ext/Syncroton/Command/Sync.php b/lib/ext/Syncroton/Command/Sync.php
index c5da42b..3308bed 100644
--- a/lib/ext/Syncroton/Command/Sync.php
+++ b/lib/ext/Syncroton/Command/Sync.php
@@ -601,7 +601,7 @@ class Syncroton_Command_Sync extends Syncroton_Command_Wbxml
$serverModifications['deleted'] = array_diff($allClientEntries, $allServerEntries);
// fetch entries changed since last sync
- $serverModifications['changed'] = $dataController->getChangedEntries($collectionData->collectionId, $collectionData->syncState->lastsync, $this->_syncTimeStamp);
+ $serverModifications['changed'] = $dataController->getChangedEntries($collectionData->collectionId, $collectionData->syncState->lastsync, $this->_syncTimeStamp, $collectionData->options['filterType']);
$serverModifications['changed'] = array_merge($serverModifications['changed'], $clientModifications['forceChange']);
foreach($serverModifications['changed'] as $id => $serverId) {
diff --git a/lib/ext/Syncroton/Data/AData.php b/lib/ext/Syncroton/Data/AData.php
index 97a821d..e99e0b9 100644
--- a/lib/ext/Syncroton/Data/AData.php
+++ b/lib/ext/Syncroton/Data/AData.php
@@ -132,7 +132,7 @@ abstract class Syncroton_Data_AData implements Syncroton_Data_IData
return $result;
}
- public function getChangedEntries($_folderId, DateTime $_startTimeStamp, DateTime $_endTimeStamp = NULL)
+ public function getChangedEntries($_folderId, DateTime $_startTimeStamp, DateTime $_endTimeStamp = NULL, $filterType = NULL)
{
if (!isset(Syncroton_Data_AData::$changedEntries[get_class($this)])) {
return array();
@@ -171,7 +171,7 @@ abstract class Syncroton_Data_AData implements Syncroton_Data_IData
$addedEntries = array_diff($allServerEntries, $allClientEntries);
$deletedEntries = array_diff($allClientEntries, $allServerEntries);
- $changedEntries = $this->getChangedEntries($folder->serverId, $syncState->lastsync);
+ $changedEntries = $this->getChangedEntries($folder->serverId, $syncState->lastsync, null, $folder->lastfiltertype);
return count($addedEntries) + count($deletedEntries) + count($changedEntries);
}
diff --git a/lib/ext/Syncroton/Data/IData.php b/lib/ext/Syncroton/Data/IData.php
index db286d3..a21dfd5 100644
--- a/lib/ext/Syncroton/Data/IData.php
+++ b/lib/ext/Syncroton/Data/IData.php
@@ -51,7 +51,7 @@ interface Syncroton_Data_IData
*/
public function getAllFolders();
- public function getChangedEntries($folderId, DateTime $startTimeStamp, DateTime $endTimeStamp = NULL);
+ public function getChangedEntries($folderId, DateTime $startTimeStamp, DateTime $endTimeStamp = NULL, $filterType = NULL);
public function getCountOfChanges(Syncroton_Backend_IContent $contentBackend, Syncroton_Model_IFolder $folder, Syncroton_Model_ISyncState $syncState);
diff --git a/lib/kolab_sync_data.php b/lib/kolab_sync_data.php
index 82d6547..795d534 100644
--- a/lib/kolab_sync_data.php
+++ b/lib/kolab_sync_data.php
@@ -517,13 +517,16 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
* @param string $folderId
* @param DateTime $start
* @param DateTime $end
+ * @param int $filterType
+ *
* @return array
*/
- public function getChangedEntries($folderId, DateTime $start, DateTime $end = null)
+ public function getChangedEntries($folderId, DateTime $start, DateTime $end = null, $filter_type = null)
{
- $filter = array(array('changed', '>', $start));
+ $filter = $this->filter($filter_type);
+ $filter[] = array('changed', '>', $start);
- if ($endTimeStamp) {
+ if ($end) {
$filter[] = array('changed', '<=', $end);
}
@@ -538,14 +541,16 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
* @param string $folderId
* @param DateTime $start
* @param DateTime $end
+ * @param int $filterType
*
* @return int
*/
- public function getChangedEntriesCount($folderId, DateTime $start, DateTime $end = null)
+ public function getChangedEntriesCount($folderId, DateTime $start, DateTime $end = null, $filter_type = null)
{
- $filter = array(array('changed', '>', $start));
+ $filter = $this->filter($filter_type);
+ $filter[] = array('changed', '>', $start);
- if ($endTimeStamp) {
+ if ($end) {
$filter[] = array('changed', '<=', $end);
}
@@ -599,7 +604,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
{
$allClientEntries = $contentBackend->getFolderState($this->device, $folder);
$allServerEntries = $this->getServerEntries($folder->serverId, $folder->lastfiltertype);
- $changedEntries = $this->getChangedEntriesCount($folder->serverId, $syncState->lastsync);
+ $changedEntries = $this->getChangedEntriesCount($folder->serverId, $syncState->lastsync, null, $folder->lastfiltertype);
$addedEntries = array_diff($allServerEntries, $allClientEntries);
$deletedEntries = array_diff($allClientEntries, $allServerEntries);
@@ -617,7 +622,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
*/
public function hasChanges(Syncroton_Backend_IContent $contentBackend, Syncroton_Model_IFolder $folder, Syncroton_Model_ISyncState $syncState)
{
- if ($this->getChangedEntriesCount($folder->serverId, $syncState->lastsync)) {
+ if ($this->getChangedEntriesCount($folder->serverId, $syncState->lastsync, null, $folder->lastfiltertype)) {
return true;
}
More information about the commits
mailing list