Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Felamimail/Account): update primary account folder cache once an …
Browse files Browse the repository at this point in the history
…hour

... also catch all exceptions during that update, because the
 error would bubble through and prevent display of accounts otherwise

Change-Id: I0ac73adef30b646dca73766cae141fd4807cdb8c
Reviewed-on: http://gerrit.tine20.com/customers/15315
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
  • Loading branch information
pschuele committed Jan 15, 2020
1 parent 2ebabf9 commit 40100c0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tine20/Felamimail/Frontend/Json.php
Expand Up @@ -480,17 +480,32 @@ public function searchAccounts($filter)
}

/**
* reload folder cache on primary account
* reload folder cache on primary account - only do this once an hour (with caching)
*
* @param $account
* @return boolean
*/
protected function _reloadFolderCacheOnPrimaryAccount($account)
{
if (Tinebase_Core::getPreference($this->_applicationName)->{Felamimail_Preference::DEFAULTACCOUNT} !== $account['id']) {
return;
return false;
}

$this->updateFolderCache($account['id'], '');
$cache = Tinebase_Core::getCache();
$cacheId = Tinebase_Helper::convertCacheId('_reloadFolderCacheOnPrimaryAccount' . $account['id']);
if ($cache->test($cacheId)) {
return $cache->load($cacheId);
}

try {
$this->updateFolderCache($account['id'], '');
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(
__METHOD__ . '::' . __LINE__ . ' Could not update account folder cache: ' . $e->getMessage()
);
}
$cache->save(true, $cacheId, [], 3600);
return true;
}

/**
Expand Down

0 comments on commit 40100c0

Please sign in to comment.