Commit 24b275a2 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-771 Indicate changed additional folderdata in

DeviceManager->IsHierarchySyncRequired().

Released under the Affero GNU General Public License (AGPL) version 3.
parent 423d9d31
...@@ -67,6 +67,7 @@ class DeviceManager { ...@@ -67,6 +67,7 @@ class DeviceManager {
private $loopdetection; private $loopdetection;
private $hierarchySyncRequired; private $hierarchySyncRequired;
private $additionalFoldersHash;
/** /**
* Constructor * Constructor
...@@ -97,6 +98,8 @@ class DeviceManager { ...@@ -97,6 +98,8 @@ class DeviceManager {
$this->stateManager = new StateManager(); $this->stateManager = new StateManager();
$this->stateManager->SetDevice($this->device); $this->stateManager->SetDevice($this->device);
$this->additionalFoldersHash = $this->getAdditionalFoldersHash();
} }
/** /**
...@@ -608,13 +611,20 @@ class DeviceManager { ...@@ -608,13 +611,20 @@ class DeviceManager {
} }
/** /**
* Indicates if the hierarchy should be resynchronized * Indicates if the hierarchy should be resynchronized based on the general folder state and
* e.g. during PING * if additional folders changed.
* *
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function IsHierarchySyncRequired() { public function IsHierarchySyncRequired() {
$this->loadDeviceData();
// if the hash of the additional folders changed, we have to sync the hierarchy
if ($this->additionalFoldersHash != $this->getAdditionalFoldersHash()) {
$this->hierarchySyncRequired = true;
}
// check if a hierarchy sync might be necessary // check if a hierarchy sync might be necessary
if ($this->device->GetFolderUUID(false) === false) if ($this->device->GetFolderUUID(false) === false)
$this->hierarchySyncRequired = true; $this->hierarchySyncRequired = true;
...@@ -622,6 +632,10 @@ class DeviceManager { ...@@ -622,6 +632,10 @@ class DeviceManager {
return $this->hierarchySyncRequired; return $this->hierarchySyncRequired;
} }
private function getAdditionalFoldersHash() {
return md5(serialize($this->device->GetAdditionalFolders()));
}
/** /**
* Indicates if a full hierarchy resync should be triggered due to loops * Indicates if a full hierarchy resync should be triggered due to loops
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment