Commit 95b61d93 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into...

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into bugfix/ZP-839-z-push-top-writes-over-several-lines
parents 0d3a0ffb cc533ab9
...@@ -194,8 +194,22 @@ class SyncCollections implements Iterator { ...@@ -194,8 +194,22 @@ class SyncCollections implements Iterator {
$addStatus = $this->AddCollection($spa); $addStatus = $this->AddCollection($spa);
// load the latest known syncstate if requested // load the latest known syncstate if requested
if ($addStatus && $loadState === true) if ($addStatus && $loadState === true) {
$this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey()); 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; return $addStatus;
} }
...@@ -639,11 +653,8 @@ class SyncCollections implements Iterator { ...@@ -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."); 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; $this->changes[$folderid] = 1;
// make sure this folder is fully synched on next Sync request // make sure this folder is fully synched on next Sync request
if($spa->HasFolderStat()) { $this->invalidateFolderStat($spa);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CountChange(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId()));
$spa->DelFolderStat();
$this->SaveCollection($spa);
}
return true; return true;
} }
throw new StatusException("SyncCollections->CountChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN); 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 { ...@@ -675,14 +686,13 @@ class SyncCollections implements Iterator {
* @return boolean * @return boolean
*/ */
public function PingableFolders() { public function PingableFolders() {
$pingable = false;
foreach ($this->collections as $folderid => $spa) { foreach ($this->collections as $folderid => $spa) {
if ($spa->GetPingableFlag() == true) if ($spa->GetPingableFlag() == true) {
$pingable = true; return true;
}
} }
return $pingable; return false;
} }
/** /**
...@@ -762,4 +772,22 @@ class SyncCollections implements Iterator { ...@@ -762,4 +772,22 @@ class SyncCollections implements Iterator {
if (!isset($this->stateManager)) if (!isset($this->stateManager))
$this->stateManager = ZPush::GetDeviceManager()->GetStateManager(); $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 { ...@@ -74,8 +74,10 @@ class Ping extends RequestProcessor {
self::$topCollector->AnnounceInformation("StateNotFoundException: require PingParameters", true); self::$topCollector->AnnounceInformation("StateNotFoundException: require PingParameters", true);
} }
else { else {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED; // we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
self::$topCollector->AnnounceInformation("StateNotFoundException: require HierarchySync", true); $fakechanges = $sc->GetChangedFolderIds();
$foundchanges = true;
self::$topCollector->AnnounceInformation("StateNotFoundException: force sync", true);
} }
} }
catch (StateInvalidException $snfex) { catch (StateInvalidException $snfex) {
......
...@@ -160,8 +160,10 @@ class Sync extends RequestProcessor { ...@@ -160,8 +160,10 @@ class Sync extends RequestProcessor {
throw new StateInvalidException("Saved state are not of type SyncParameters"); throw new StateInvalidException("Saved state are not of type SyncParameters");
// new/resync requested // new/resync requested
if ($synckey == "0") if ($synckey == "0") {
$spa->RemoveSyncKey(); $spa->RemoveSyncKey();
$spa->DelFolderStat();
}
else if ($synckey !== false) else if ($synckey !== false)
$spa->SetSyncKey($synckey); $spa->SetSyncKey($synckey);
} }
......
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