Commit 6e560437 authored by skummer's avatar skummer

ZP-389 #comment if no ping initialize data is sent, check if there are any...

ZP-389 #comment if no ping initialize data is sent, check if there are any pingable folders. If not, indicate failing params. #time 40m

git-svn-id: https://z-push.org/svn/z-push/trunk@1670 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 8c0ddd96
...@@ -214,6 +214,7 @@ class SyncCollections implements Iterator { ...@@ -214,6 +214,7 @@ class SyncCollections implements Iterator {
public function AddCollection($spa) { public function AddCollection($spa) {
$this->collections[$spa->GetFolderId()] = $spa; $this->collections[$spa->GetFolderId()] = $spa;
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->AddCollection(): Folder id '%s' : ref. PolicyKey '%s', ref. Lifetime '%s', last sync at '%s'", $spa->GetFolderId(), $spa->GetReferencePolicyKey(), $spa->GetReferenceLifetime(), $spa->GetLastSyncTime()));
if ($spa->HasLastSyncTime() && $spa->GetLastSyncTime() > $this->lastSyncTime) { if ($spa->HasLastSyncTime() && $spa->GetLastSyncTime() > $this->lastSyncTime) {
$this->lastSyncTime = $spa->GetLastSyncTime(); $this->lastSyncTime = $spa->GetLastSyncTime();
...@@ -224,6 +225,8 @@ class SyncCollections implements Iterator { ...@@ -224,6 +225,8 @@ class SyncCollections implements Iterator {
// use SyncParameters LifeTime as reference if available // use SyncParameters LifeTime as reference if available
if ($spa->HasReferenceLifetime()) if ($spa->HasReferenceLifetime())
$this->refLifetime = $spa->GetReferenceLifetime(); $this->refLifetime = $spa->GetReferenceLifetime();
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->AddCollection(): Updated reference PolicyKey '%s', reference Lifetime '%s', Last sync at '%s'", $this->refPolicyKey, $this->refLifetime, $spa->GetFolderId(),$this->lastSyncTime));
} }
return true; return true;
...@@ -603,6 +606,23 @@ class SyncCollections implements Iterator { ...@@ -603,6 +606,23 @@ class SyncCollections implements Iterator {
return $this->changes; return $this->changes;
} }
/**
* Indicates if there are folders which are pingable
*
* @access public
* @return boolean
*/
public function PingableFolders() {
$pingable = false;
foreach ($this->collections as $folderid => $spa) {
if ($spa->GetPingableFlag() == true)
$pingable = true;
}
return $pingable;
}
/** /**
* Indicates if the process did wait in a sink, polling or before running a * Indicates if the process did wait in a sink, polling or before running a
* regular export to find changes * regular export to find changes
......
...@@ -147,10 +147,18 @@ class Ping extends RequestProcessor { ...@@ -147,10 +147,18 @@ class Ping extends RequestProcessor {
foreach ($sc as $folderid => $spa) foreach ($sc as $folderid => $spa)
$sc->SaveCollection($spa); $sc->SaveCollection($spa);
} // END SYNC_PING_PING } // END SYNC_PING_PING
else {
// if no ping initialization data was sent, we check if we have pingable folders
// if not, we indicate that there is nothing to do.
if (! $sc->PingableFolders()) {
$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
ZLog::Write(LOGLEVEL_DEBUG, "HandlePing(): no pingable folders found and no initialization data sent. Returning SYNC_PINGSTATUS_FAILINGPARAMS.");
}
}
// Check for changes on the default LifeTime, set interval and ONLY on pingable collections // Check for changes on the default LifeTime, set interval and ONLY on pingable collections
try { try {
if (empty($fakechanges)) { if (!$pingstatus && empty($fakechanges)) {
$foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval, true); $foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval, true);
} }
} }
......
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