Commit 45cd6bec authored by Sebastian Kummer's avatar Sebastian Kummer

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.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 0a7587a4
......@@ -203,6 +203,9 @@ class SyncCollections implements Iterator {
// 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;
}
......@@ -650,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);
......@@ -686,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;
}
/**
......@@ -773,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;
}
}
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