Commit 418020e6 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1035 Catch if a store can not be found and don't try to synchronize

data in this case.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 6c1f546a
......@@ -113,6 +113,9 @@ class Kopano extends SyncWorker {
*/
protected function createHiddenFolder($gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store);
// mapi_folder_createfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
......@@ -145,6 +148,9 @@ class Kopano extends SyncWorker {
*/
protected function deleteHiddenFolder($folderid, $gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store);
$folderentryid = mapi_msgstore_entryidfromsourcekey($store, hex2bin($folderid));
......@@ -169,6 +175,9 @@ class Kopano extends SyncWorker {
*/
protected function getHiddenFolderId($gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store);
$table = mapi_folder_gethierarchytable($parentfolder);
......@@ -198,6 +207,9 @@ class Kopano extends SyncWorker {
protected function clearFolderContents($folderid, $gabId = null, $gabName = 'default') {
$this->Log(sprintf("Kopano->clearFolderContents: emptying folder in GAB '%s': %s", $gabName, $folderid));
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$folder = $this->getFolder($store, $folderid);
// empty folder!
......@@ -221,6 +233,9 @@ class Kopano extends SyncWorker {
*/
protected function clearAllNotCurrentChunkType($folderid, $gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$folder = $this->getFolder($store, $folderid);
$table = mapi_folder_getcontentstable($folder);
if (!$table)
......@@ -432,6 +447,9 @@ class Kopano extends SyncWorker {
protected function getChunkData($folderid, $chunkName, $gabId = null, $gabName = 'default') {
// find the chunk message in the folder
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$chunkdata = $this->findChunk($store, $folderid, $chunkName);
if (isset($chunkdata[PR_ENTRYID])) {
......@@ -466,6 +484,9 @@ class Kopano extends SyncWorker {
// find the chunk message in the folder
$store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$chunkdata = $this->findChunk($store, $folderid, $chunkName);
$message = false;
......@@ -619,8 +640,14 @@ class Kopano extends SyncWorker {
if (!isset($this->storeCache[$gabId])) {
$user = (strtoupper($this->targetStore) == 'SYSTEM') ? $gabName : $this->targetStore . "@" . $gabName;
$store_entryid = mapi_msgstore_createentryid($this->store, $user);
$store = mapi_openmsgstore($this->session, $store_entryid);
$this->Log(sprintf("Kopano->getStore(): Found store of user '%s': '%s'", $user, $store));
if ($store_entryid) {
$store = mapi_openmsgstore($this->session, $store_entryid);
$this->Log(sprintf("Kopano->getStore(): Found store of user '%s': '%s'", $user, $store));
}
else {
$this->Log(sprintf("Kopano->getStore(): No store found for '%s'", $user));
$store = false;
}
$this->storeCache[$gabId] = $store;
}
......
......@@ -117,6 +117,10 @@ abstract class SyncWorker {
private function doSync($gabId = null, $gabName = 'default', $doWrite = true) {
// get the folderid of the hidden folder - will be created if not yet available
$folderid = $this->getFolderId($gabId, $gabName, $doWrite);
if ($folderid === false) {
$this->Log(sprintf("Aborting %sGAB sync to store '%s'%s. Store not found or create not possible.", (!$doWrite?"simulated ":""), HIDDEN_FOLDERSTORE, ($gabId?" of '".$gabName."'":"")));
return;
}
$this->Log(sprintf("Starting %sGAB sync to store '%s' %s on id '%s'", (!$doWrite?"simulated ":""), HIDDEN_FOLDERSTORE, ($gabId?"of '".$gabName."'":""), $folderid));
......
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