Commit 7013c516 authored by sebastian's avatar sebastian

ZP-623 #comment if exporting more than 1000 delete requests throw...

ZP-623 #comment if exporting more than 1000 delete requests throw StatusException, remove folder states if statusexception is received during export, reset status to success only after saving the folder states, do no throw hierarchy-changed in ping when a state can not be found and no ping parameters were sent

git-svn-id: https://z-push.org/svn/z-push/trunk@1963 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 4bda5a06
...@@ -157,6 +157,9 @@ class PHPWrapper { ...@@ -157,6 +157,9 @@ class PHPWrapper {
* @return * @return
*/ */
public function ImportMessageDeletion($flags, $sourcekeys) { public function ImportMessageDeletion($flags, $sourcekeys) {
if (count($sourcekeys) > 1000) {
throw new StatusException("ImportChangesICS->ImportMessageDeletion(): Detected more than 1000 remove requests from ICS. Triggering folder re-sync.", SYNC_STATUS_INVALIDSYNCKEY, null, LOGLEVEL_ERROR);
}
foreach($sourcekeys as $sourcekey) { foreach($sourcekeys as $sourcekey) {
$this->importer->ImportMessageDeletion(bin2hex($sourcekey)); $this->importer->ImportMessageDeletion(bin2hex($sourcekey));
} }
......
...@@ -60,13 +60,23 @@ class Ping extends RequestProcessor { ...@@ -60,13 +60,23 @@ class Ping extends RequestProcessor {
// Contains all requested folders (containers) // Contains all requested folders (containers)
$sc = new SyncCollections(); $sc = new SyncCollections();
// read from stream to see if the symc params are being sent
$params_present = self::$decoder->getElementStartTag(SYNC_PING_PING);
// Load all collections - do load states and check permissions // Load all collections - do load states and check permissions
try { try {
$sc->LoadAllCollections(true, true, true); $sc->LoadAllCollections(true, true, true);
} }
catch (StateNotFoundException $snfex) { catch (StateNotFoundException $snfex) {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED; // if no params are present, indicate to send params, else do hierarchy sync
self::$topCollector->AnnounceInformation("StateNotFoundException: require HierarchySync", true); if (!$params_present) {
$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
self::$topCollector->AnnounceInformation("StateNotFoundException: require PingParameters", true);
}
else {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
self::$topCollector->AnnounceInformation("StateNotFoundException: require HierarchySync", true);
}
} }
catch (StateInvalidException $snfex) { catch (StateInvalidException $snfex) {
// we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken // we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
...@@ -83,7 +93,7 @@ class Ping extends RequestProcessor { ...@@ -83,7 +93,7 @@ class Ping extends RequestProcessor {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): reference PolicyKey for PING: %s", $sc->GetReferencePolicyKey())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): reference PolicyKey for PING: %s", $sc->GetReferencePolicyKey()));
// receive PING initialization data // receive PING initialization data
if(self::$decoder->getElementStartTag(SYNC_PING_PING)) { if($params_present) {
self::$topCollector->AnnounceInformation("Processing PING data"); self::$topCollector->AnnounceInformation("Processing PING data");
ZLog::Write(LOGLEVEL_DEBUG, "HandlePing(): initialization data received"); ZLog::Write(LOGLEVEL_DEBUG, "HandlePing(): initialization data received");
......
...@@ -925,6 +925,15 @@ class Sync extends RequestProcessor { ...@@ -925,6 +925,15 @@ class Sync extends RequestProcessor {
self::$deviceManager->AnnounceIgnoredMessage($spa->GetFolderId(), $brokenSO->id, $brokenSO); self::$deviceManager->AnnounceIgnoredMessage($spa->GetFolderId(), $brokenSO->id, $brokenSO);
} }
} }
// something really bad happened while exporting changes
catch (StatusException $stex) {
$status = $stex->getCode();
// during export we found out that the states should be thrown away (ZP-623)
if ($status == SYNC_STATUS_INVALIDSYNCKEY) {
self::$deviceManager->ForceFolderResync($spa->GetFolderId());
break;
}
}
if($n >= $windowSize) { if($n >= $windowSize) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Exported maxItems of messages: %d / %d", $n, $changecount)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Exported maxItems of messages: %d / %d", $n, $changecount));
...@@ -981,13 +990,14 @@ class Sync extends RequestProcessor { ...@@ -981,13 +990,14 @@ class Sync extends RequestProcessor {
ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): error saving '%s' - no state information available", $spa->GetNewSyncKey())); ZLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): error saving '%s' - no state information available", $spa->GetNewSyncKey()));
} }
// reset status for the next folder
$status = SYNC_STATUS_SUCCESS;
// save SyncParameters // save SyncParameters
if ($status == SYNC_STATUS_SUCCESS && empty($actiondata["fetchids"])) if ($status == SYNC_STATUS_SUCCESS && empty($actiondata["fetchids"]))
$sc->SaveCollection($spa); $sc->SaveCollection($spa);
// reset status for the next folder
$status = SYNC_STATUS_SUCCESS;
} // END foreach collection } // END foreach collection
} }
self::$encoder->endTag(); //SYNC_FOLDERS self::$encoder->endTag(); //SYNC_FOLDERS
......
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