From 2b072dad59b9ebebb2f1be5edc141473e0b013a8 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Thu, 22 Apr 2010 10:23:15 -0400 Subject: [PATCH] Have the state object be responsible for stating the message if needed. This allows different state drivers to omit the stat if it's not necessary for determining changes. --- framework/ActiveSync/lib/Horde/ActiveSync/State/File.php | 8 ++++++++ framework/ActiveSync/lib/Horde/ActiveSync/Sync.php | 11 ++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php index 384c638a7..2d7f92346 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php @@ -197,6 +197,14 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base // Change can be a change or an add if ($type == 'change') { + /* If we are a change and don't already have a mod time, stat the + * message. This would only happen when exporting a server side + * change. We need the mod time to track the version of the message + * on the PIM. + */ + if (!isset($change['mod'])) { + $change = $this->_backend->statMessage($this->_collection['id'], $change['id']); + } for($i = 0; $i < count($this->_stateCache); $i++) { if($this->_stateCache[$i]['id'] == $change['id']) { $this->_stateCache[$i] = $change; diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php b/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php index 7cc098d22..ac5900dd6 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Sync.php @@ -178,21 +178,14 @@ class Horde_ActiveSync_Sync switch($change['type']) { case 'change': $truncsize = self::_getTruncSize($this->_truncation); - // Note: because 'parseMessage' and 'statMessage' are two seperate - // calls, we have a chance that the message has changed between both - // calls. This may cause our algorithm to 'double see' changes. - $stat = $this->_backend->statMessage($this->_folderId, $change['id']); if (!$message = $this->_backend->getMessage($this->_folderId, $change['id'], $truncsize)) { return false; } // copy the flag to the message $message->flags = (isset($change['flags'])) ? $change['flags'] : 0; - - if ($stat && $message) { - if ($flags & Horde_ActiveSync::BACKEND_DISCARD_DATA || $this->_exporter->messageChange($change['id'], $message) == true) { - $this->_stateMachine->updateState('change', $stat); - } + if ($flags & Horde_ActiveSync::BACKEND_DISCARD_DATA || $this->_exporter->messageChange($change['id'], $message) == true) { + $this->_stateMachine->updateState('change', $change); } break; -- 2.11.0