More folderlist speedups

This commit is contained in:
djmaze 2021-10-29 10:08:42 +02:00
parent 76630f593d
commit 12ebe4c3a0
4 changed files with 12 additions and 16 deletions

View file

@ -155,7 +155,7 @@ class ImapClient extends \MailSo\Net\NetClient
try
{
if (0 === \strpos($type, 'SCRAM-SHA-'))
if (0 === \strpos($type, 'SCRAM-'))
{
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid*/), true);
@ -759,7 +759,7 @@ class ImapClient extends \MailSo\Net\NetClient
private function simpleESearchOrESortHelper(bool $bSort = false, string $sSearchCriterias = 'ALL', array $aSearchOrSortReturn = null, bool $bReturnUid = true, string $sLimit = '', string $sCharset = '', array $aSortTypes = null) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias
$sSearchCriterias = !\strlen($sSearchCriterias) || '*' === $sSearchCriterias
? 'ALL' : $sSearchCriterias;
$sCmd = $bSort ? 'SORT': 'SEARCH';
@ -939,7 +939,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function MessageCopy(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{
if (0 === \strlen($sIndexRange))
if (!\strlen($sIndexRange))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException,
@ -959,7 +959,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function MessageMove(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{
if (0 === \strlen($sIndexRange))
if (!\strlen($sIndexRange))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException,

View file

@ -180,7 +180,7 @@ class ResponseCollection extends \MailSo\Base\Collection
$sDelimiter = $oFolder->Delimiter();
}
$aReturn[] = $oFolder;
$aReturn[$sFullNameRaw] = $oFolder;
}
catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException)
{
@ -197,8 +197,8 @@ class ResponseCollection extends \MailSo\Base\Collection
}
}
if (!$bInbox && !empty($sDelimiter)) {
$aReturn[] = new Folder('INBOX', $sDelimiter);
if (!$bInbox && !empty($sDelimiter) && !isset($aReturn['INBOX'])) {
$aReturn['INBOX'] = new Folder('INBOX', $sDelimiter);
}
if ($bUseListStatus) {
@ -208,11 +208,8 @@ class ResponseCollection extends \MailSo\Base\Collection
isset($oResponse->ResponseList[2]))
{
$sFolderNameRaw = $oResponse->ResponseList[2];
foreach ($aReturn as $oFolder) {
if ($oFolder && $sFolderNameRaw === $oFolder->FullNameRaw()) {
$oFolder->setStatusFromResponse($oResponse);
break;
}
if (isset($aReturn[$sFolderNameRaw])) {
$aReturn[$sFolderNameRaw]->setStatusFromResponse($oResponse);
}
}
}

View file

@ -492,7 +492,7 @@ trait ResponseParser
{
$bCountTwoInited = true;
$oImapResponse->StatusOrIndex = strtoupper($aList[1]);
$oImapResponse->StatusOrIndex = \strtoupper($aList[1]);
if ($oImapResponse->StatusOrIndex == ResponseStatus::OK ||
$oImapResponse->StatusOrIndex == ResponseStatus::NO ||

View file

@ -1976,14 +1976,13 @@ class MailClient
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
$aFolders = $this->oImapClient->FolderList('', $sPrevFolderFullNameRaw);
if (!$aFolders)
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullNameRaw);
if (!$sDelimiter)
{
// TODO: Translate
throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.');
}
$sDelimiter = $aFolders[0]->Delimiter();
$iLast = \strrpos($sPrevFolderFullNameRaw, $sDelimiter);
$aSubscribeFolders = array();