Commit 2c8b3b39 authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #174 in ZP/z-push from bugfix/ZP-853-backend-could-not-support-folderstats to develop

* commit '9f29e7bf':
  ZP-853 Allow a return value of false for single folders when calling Backend->GetFolderStat(). In this case, in Sync the exporter will always run for these folders. In Ping the initial checkup (generate fake changes and force a Sync on this folder if the stat does not match or expired) can not be executed.
parents 8fcb38b5 9f29e7bf
...@@ -518,7 +518,8 @@ class SyncCollections implements Iterator { ...@@ -518,7 +518,8 @@ class SyncCollections implements Iterator {
} }
// check if the folder stat changed since the last sync, if so generate a change for it (only on first run) // check if the folder stat changed since the last sync, if so generate a change for it (only on first run)
if ($this->waitingTime == 0 && ZPush::GetBackend()->HasFolderStats() && $spa->IsExporterRunRequired(ZPush::GetBackend()->GetFolderStat($store, $spa->GetFolderId()), true)) { $currentFolderStat = ZPush::GetBackend()->GetFolderStat($store, $spa->GetFolderId());
if ($this->waitingTime == 0 && ZPush::GetBackend()->HasFolderStats() && $currentFolderStat !== false && $spa->IsExporterRunRequired($currentFolderStat, true)) {
$this->changes[$spa->GetFolderId()] = 1; $this->changes[$spa->GetFolderId()] = 1;
} }
} }
......
...@@ -287,10 +287,17 @@ class SyncParameters extends StateObject { ...@@ -287,10 +287,17 @@ class SyncParameters extends StateObject {
* @return boolean * @return boolean
*/ */
public function IsExporterRunRequired($currentFolderStat, $doLog = false) { public function IsExporterRunRequired($currentFolderStat, $doLog = false) {
$run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); // if the backend returned false as folderstat, we have to run the exporter
if ($currentFolderStat === false) {
$run = true;
}
else {
// check if the folderstat differs from the saved one or expired
$run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout());
}
if ($doLog) { if ($doLog) {
$expDate = ($this->HasFolderStatTimeout()) ? date('Y-m-d H:i:s', $this->GetFolderStatTimeout()) : "not set"; $expDate = ($this->HasFolderStatTimeout()) ? date('Y-m-d H:i:s', $this->GetFolderStatTimeout()) : "not set";
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->IsExporterRunRequired(): %s - current: %s - saved: %s - expiring: %s", Utils::PrintAsString($run), $currentFolderStat, Utils::PrintAsString($this->GetFolderStat()), $expDate)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->IsExporterRunRequired(): %s - current: %s - saved: %s - expiring: %s", Utils::PrintAsString($run), Utils::PrintAsString($currentFolderStat), Utils::PrintAsString($this->GetFolderStat()), $expDate));
} }
return $run; return $run;
} }
......
...@@ -741,7 +741,7 @@ class Sync extends RequestProcessor { ...@@ -741,7 +741,7 @@ class Sync extends RequestProcessor {
if ($setupExporter && self::$backend->HasFolderStats()) { if ($setupExporter && self::$backend->HasFolderStats()) {
// check if the folder stats changed -> if not, don't setup the exporter, there are no changes! // check if the folder stats changed -> if not, don't setup the exporter, there are no changes!
$newFolderStat = self::$backend->GetFolderStat(ZPush::GetAdditionalSyncFolderStore($spa->GetFolderId()), $spa->GetFolderId()); $newFolderStat = self::$backend->GetFolderStat(ZPush::GetAdditionalSyncFolderStore($spa->GetFolderId()), $spa->GetFolderId());
if (! $spa->IsExporterRunRequired($newFolderStat, true)) { if ($newFolderStat !== false && ! $spa->IsExporterRunRequired($newFolderStat, true)) {
$changecount = 0; $changecount = 0;
$setupExporter = false; $setupExporter = false;
ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Folder stat from the backend indicates that the folder did not change. Exporter will not run."); ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Folder stat from the backend indicates that the folder did not change. Exporter will not run.");
...@@ -828,7 +828,7 @@ class Sync extends RequestProcessor { ...@@ -828,7 +828,7 @@ class Sync extends RequestProcessor {
// Fir AS 14.0+ omit output for folder, if there were no incoming or outgoing changes and no Fetch // Fir AS 14.0+ omit output for folder, if there were no incoming or outgoing changes and no Fetch
if (Request::GetProtocolVersion() >= 14.0 && ! $spa->HasNewSyncKey() && $changecount == 0 && empty($actiondata["fetchids"]) && $status == SYNC_STATUS_SUCCESS && if (Request::GetProtocolVersion() >= 14.0 && ! $spa->HasNewSyncKey() && $changecount == 0 && empty($actiondata["fetchids"]) && $status == SYNC_STATUS_SUCCESS &&
! $spa->IsExporterRunRequired($newFolderStat)) { ($newFolderStat === false || ! $spa->IsExporterRunRequired($newFolderStat))) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: No changes found for %s folder id '%s'. Omitting output.", $spa->GetContentClass(), $spa->GetFolderId())); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: No changes found for %s folder id '%s'. Omitting output.", $spa->GetContentClass(), $spa->GetFolderId()));
continue; continue;
} }
......
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