Commit 85f75f81 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-846 If folderdata is found also check if the synckey corresponds to

the latest hierarchy synckey and update it if not.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 179d735c
...@@ -864,24 +864,38 @@ class ZPushAdmin { ...@@ -864,24 +864,38 @@ 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;
$allStates = ZPush::GetStateMachine()->GetAllStatesForDevice($devid); }
$maxCounter = 1; // Search all states, and find the highest counter for the hierarchy UUID
foreach ($allStates as $state) { $allStates = ZPush::GetStateMachine()->GetAllStatesForDevice($devid);
if ($state["uuid"] == $hierarchyUuid && $state['counter'] > $maxCounter && ($state['type'] == "" || $state['type'] == false)) { $maxCounter = 1;
$maxCounter = $state['counter']; foreach ($allStates as $state) {
} if ($state["uuid"] == $hierarchyUuid && $state['counter'] > $maxCounter && ($state['type'] == "" || $state['type'] == false)) {
$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