Skip to content

Commit

Permalink
Use the uid map, and save tons of database calls to load the syncCache.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 17, 2013
1 parent b70fc22 commit 3a6a1a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
10 changes: 7 additions & 3 deletions framework/ActiveSync/lib/Horde/ActiveSync/Collections.php
Expand Up @@ -316,10 +316,14 @@ public function getBackendIdForFolderUid($folderid)
*
* @return string The EAS uid.
*/

public function getFolderUidForBackendId($id)
public function getFolderUidForBackendId($folderid)
{
return $this->_as->state->getFolderUidForBackendId($id);
$map = $this->_as->state->getFolderUidToBankendIdMap();
if (empty($map[$folderid])) {
return false;
}

return $map[$folderid];
}

/**
Expand Down
22 changes: 13 additions & 9 deletions framework/ActiveSync/lib/Horde/ActiveSync/Driver/Base.php
Expand Up @@ -351,17 +351,21 @@ static public function buildFbString($fb, Horde_Date $start, Horde_Date $end)
*/
protected function _getFolderUidForBackendId($imap)
{
if ($id = $this->_state->getFolderUidForBackendId($imap)) {
return $id;
} elseif (empty($this->_tempMap[$imap])) {
$this->_tempMap[$imap] = sprintf('F%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
$this->_logger->info(sprintf(
'[%s] Creating new folder uuid for %s: %s',
getmypid(),
$imap,
$this->_tempMap[$imap]));
$map = $this->_state->getFolderUidToBackendIdMap();
if (!empty($map[$imap])) {
return $map[$imap];
} elseif (!empty($this->_tempMap[$imap])) {
return $this->_tempMap[$imap];
}

// None found, generate a new UID.
$this->_tempMap[$imap] = sprintf('F%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
$this->_logger->info(sprintf(
'[%s] Creating new folder uuid for %s: %s',
getmypid(),
$imap,
$this->_tempMap[$imap]));

return $this->_tempMap[$imap];
}

Expand Down

0 comments on commit 3a6a1a3

Please sign in to comment.