Commit e7249ef5 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #186 in ZP/z-push from...

Merge pull request #186 in ZP/z-push from bugfix/ZP-846-z-push-admin-fix-states-need-to-fix to develop

* commit '578af98f':
  ZP-846 Update year.
  ZP-846 If folderdata is found also check if the synckey corresponds to the latest hierarchy synckey and update it if not.
parents 510352c6 578af98f
......@@ -6,7 +6,7 @@
*
* Created : 23.12.2011
*
* Copyright 2007 - 2015 Zarafa Deutschland GmbH
* Copyright 2007 - 2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
......@@ -864,13 +864,17 @@ class ZPushAdmin {
continue;
}
$seen++;
$needsFixing = false;
$spa = false;
// try getting the FOLDERDATA for that state
try {
$data = ZPush::GetStateMachine()->GetState($device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid);
$spa = ZPush::GetStateMachine()->GetState($device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid);
}
catch(StateNotFoundException $snfe) {
// No FD found, search all states, and find the highest counter for the hierarchy UUID
$needsFixing = true;
}
// Search all states, and find the highest counter for the hierarchy UUID
$allStates = ZPush::GetStateMachine()->GetAllStatesForDevice($devid);
$maxCounter = 1;
foreach ($allStates as $state) {
......@@ -878,10 +882,20 @@ class ZPushAdmin {
$maxCounter = $state['counter'];
}
}
$hierarchySyncKey = StateManager::BuildStateKey($hierarchyUuid, $maxCounter);
// generate FOLDERDATA
if ($spa) {
if ($spa->GetSyncKey() !== $hierarchySyncKey) {
$needsFixing = true;
}
}
else {
$spa = new SyncParameters();
$spa->SetSyncKey(StateManager::BuildStateKey($hierarchyUuid, $maxCounter));
}
if ($needsFixing) {
// generate FOLDERDATA
$spa->SetSyncKey($hierarchySyncKey);
$spa->SetFolderId(false);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::FixStatesHierarchyFolderData(): write data for %s", $spa->GetSyncKey()));
ZPush::GetStateMachine()->SetState($spa, $device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid);
......
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