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 @@ ...@@ -6,7 +6,7 @@
* *
* Created : 23.12.2011 * 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 * 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, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -864,13 +864,17 @@ class ZPushAdmin { ...@@ -864,13 +864,17 @@ class ZPushAdmin {
continue; continue;
} }
$seen++; $seen++;
$needsFixing = false;
$spa = false;
// try getting the FOLDERDATA for that state // try getting the FOLDERDATA for that state
try { try {
$data = ZPush::GetStateMachine()->GetState($device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid); $spa = ZPush::GetStateMachine()->GetState($device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid);
} }
catch(StateNotFoundException $snfe) { 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); $allStates = ZPush::GetStateMachine()->GetAllStatesForDevice($devid);
$maxCounter = 1; $maxCounter = 1;
foreach ($allStates as $state) { foreach ($allStates as $state) {
...@@ -878,10 +882,20 @@ class ZPushAdmin { ...@@ -878,10 +882,20 @@ class ZPushAdmin {
$maxCounter = $state['counter']; $maxCounter = $state['counter'];
} }
} }
$hierarchySyncKey = StateManager::BuildStateKey($hierarchyUuid, $maxCounter);
// generate FOLDERDATA if ($spa) {
if ($spa->GetSyncKey() !== $hierarchySyncKey) {
$needsFixing = true;
}
}
else {
$spa = new SyncParameters(); $spa = new SyncParameters();
$spa->SetSyncKey(StateManager::BuildStateKey($hierarchyUuid, $maxCounter)); }
if ($needsFixing) {
// generate FOLDERDATA
$spa->SetSyncKey($hierarchySyncKey);
$spa->SetFolderId(false); $spa->SetFolderId(false);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::FixStatesHierarchyFolderData(): write data for %s", $spa->GetSyncKey())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::FixStatesHierarchyFolderData(): write data for %s", $spa->GetSyncKey()));
ZPush::GetStateMachine()->SetState($spa, $device->GetDeviceId(), IStateMachine::FOLDERDATA, $hierarchyUuid); 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