lib/ext

Aleksander Machniak machniak at kolabsys.com
Mon Jan 14 11:03:48 CET 2013


 lib/ext/Syncroton/Server.php |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit b29c163107735c049e7d3d5768db09b1e096033d
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Jan 14 11:03:14 2013 +0100

    Skip redundant device data updates (Bug #1118)

diff --git a/lib/ext/Syncroton/Server.php b/lib/ext/Syncroton/Server.php
index dc1064e..2ae9a75 100644
--- a/lib/ext/Syncroton/Server.php
+++ b/lib/ext/Syncroton/Server.php
@@ -366,7 +366,7 @@ class Syncroton_Server
     
     /**
      * get existing device of owner or create new device for owner
-     * 
+     *
      * @param unknown_type $ownerId
      * @param unknown_type $deviceId
      * @param unknown_type $deviceType
@@ -378,12 +378,19 @@ class Syncroton_Server
     {
         try {
             $device = $this->_deviceBackend->getUserDevice($ownerId, $requestParameters['deviceId']);
-        
-            $device->useragent  = $requestParameters['userAgent'];
-            $device->acsversion = $requestParameters['protocolVersion'];
-            
-            $device = $this->_deviceBackend->update($device);
-        
+
+            if ($device->useragent != $requestParameters['userAgent']) {
+                $device->useragent = $requestParameters['userAgent'];
+                $need_update = true;
+            }
+            if ($device->acsversion != $requestParameters['protocolVersion']) {
+                $device->acsversion = $requestParameters['protocolVersion'];
+                $need_update = true;
+            }
+
+            if ($need_update) {
+                $device = $this->_deviceBackend->update($device);
+            }
         } catch (Syncroton_Exception_NotFound $senf) {
             $device = $this->_deviceBackend->create(new Syncroton_Model_Device(array(
                 'owner_id'   => $ownerId,
@@ -394,7 +401,7 @@ class Syncroton_Server
                 'policyId'   => Syncroton_Registry::isRegistered(Syncroton_Registry::DEFAULT_POLICY) ? Syncroton_Registry::get(Syncroton_Registry::DEFAULT_POLICY) : null
             )));
         }
-        
+
         return $device;
     }
-}
\ No newline at end of file
+}





More information about the commits mailing list