Commit cc533ab9 authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #152 in ZP/z-push from bugfix/ZP-840-ping-loop-if-exporter-state-is-not to develop

* commit '45cd6bec':
  ZP-840 Invalidate the folder stats in case the exporter state can not be found, improved PingableFolders(), refactored folder stat invalidated into a private method.
  ZP-840 On StateNotFoundException of the exporter state generate a fake change so Ping indicates the synchronization of the folder.
parents c54b46ea 45cd6bec
......@@ -194,8 +194,22 @@ class SyncCollections implements Iterator {
$addStatus = $this->AddCollection($spa);
// load the latest known syncstate if requested
if ($addStatus && $loadState === true)
if ($addStatus && $loadState === true) {
try {
$this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey());
}
catch (StateNotFoundException $snfe) {
// if we can't find the state, first we should try a sync of that folder, so
// we generate a fake change, so a sync on this folder is triggered
$this->changes[$folderid] = 1;
// make sure this folder is fully synched on next Sync request
$this->invalidateFolderStat($spa);
// rethrow the exception
throw $snfe;
}
}
return $addStatus;
}
......@@ -639,11 +653,8 @@ class SyncCollections implements Iterator {
ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): exporter can not be re-configured due to state error, emulating change in folder to force Sync.");
$this->changes[$folderid] = 1;
// make sure this folder is fully synched on next Sync request
if($spa->HasFolderStat()) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CountChange(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId()));
$spa->DelFolderStat();
$this->SaveCollection($spa);
}
$this->invalidateFolderStat($spa);
return true;
}
throw new StatusException("SyncCollections->CountChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN);
......@@ -675,14 +686,13 @@ class SyncCollections implements Iterator {
* @return boolean
*/
public function PingableFolders() {
$pingable = false;
foreach ($this->collections as $folderid => $spa) {
if ($spa->GetPingableFlag() == true)
$pingable = true;
if ($spa->GetPingableFlag() == true) {
return true;
}
}
return $pingable;
return false;
}
/**
......@@ -762,4 +772,22 @@ class SyncCollections implements Iterator {
if (!isset($this->stateManager))
$this->stateManager = ZPush::GetDeviceManager()->GetStateManager();
}
/**
* Remove folder statistics from a SyncParameter object.
*
* @param SyncParameters $spa
*
* @access public
* @return
*/
private function invalidateFolderStat($spa) {
if($spa->HasFolderStat()) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->invalidateFolderStat(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId()));
$spa->DelFolderStat();
$this->SaveCollection($spa);
return true;
}
return false;
}
}
......@@ -74,8 +74,10 @@ class Ping extends RequestProcessor {
self::$topCollector->AnnounceInformation("StateNotFoundException: require PingParameters", true);
}
else {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
self::$topCollector->AnnounceInformation("StateNotFoundException: require HierarchySync", true);
// we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
$fakechanges = $sc->GetChangedFolderIds();
$foundchanges = true;
self::$topCollector->AnnounceInformation("StateNotFoundException: force sync", true);
}
}
catch (StateInvalidException $snfex) {
......
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